return provider;
}
-static
-void dialog_FatalVa (vlc_object_t *obj, const char *title,
- const char *fmt, va_list ap)
+/**
+ * Sends an error message through the user interface (if any).
+ * @param obj the VLC object emitting the error
+ * @param modal whether to wait for user to acknowledge the error
+ * before returning control to the caller
+ * @param title title of the error dialog
+ * @param fmt format string for the error message
+ * @param ap parameters list for the formatted error message
+ */
+void dialog_VFatal (vlc_object_t *obj, bool modal, const char *title,
+ const char *fmt, va_list ap)
{
char *text;
return;
}
- if (vasprintf (&text, fmt, ap) == -1)
- return;
-
- dialog_fatal_t dialog = { title, text, };
- var_SetAddress (provider, "dialog-fatal", &dialog);
- free (text);
+ if (vasprintf (&text, fmt, ap) != -1)
+ {
+ dialog_fatal_t dialog = { title, text, modal, };
+ var_SetAddress (provider, "dialog-fatal", &dialog);
+ free (text);
+ }
+ vlc_object_release (provider);
}
-#undef dialog_Fatal
+#undef dialog_Login
/**
- * Notify the user of some fatal error.
- * This is a fire and forget function.
+ * Requests a username and password through the user interface.
+ * @param obj the VLC object requesting credential informations
+ * @param username a pointer to the specified username [OUT]
+ * @param password a pointer to the specified password [OUT]
+ * @param title title for the dialog
+ * @param text text for the dialog
+ * @return Nothing. If a user name resp. a password was specified,
+ * it will be returned as a heap-allocated character array
+ * into the username resp password pointer. Those must be freed with free().
+ * Otherwise *username resp *password will be NULL.
*/
-void dialog_Fatal (vlc_object_t *obj, const char *title, const char *fmt, ...)
+void dialog_Login (vlc_object_t *obj, char **username, char **password,
+ const char *title, const char *text)
{
- va_list ap;
+ assert ((username != NULL) && (password != NULL));
+
+ *username = *password = NULL;
+ if (obj->i_flags & OBJECT_FLAGS_NOINTERACT)
+ return;
+
+ vlc_object_t *provider = dialog_GetProvider (obj);
+ if (provider == NULL)
+ return;
- va_start (ap, fmt);
- dialog_FatalVa (obj, title, fmt, ap);
- va_end (ap);
+ dialog_login_t dialog = { title, text, username, password, };
+ var_SetAddress (provider, "dialog-login", &dialog);
+ vlc_object_release (provider);
}