25 #include "application.h"
28 #include "manager_p.h"
30 #include <libaccounts-glib/ag-account.h>
93 using namespace Accounts;
95 void Manager::Private::init(
Manager *q, AgManager *manager)
97 Q_ASSERT(q_ptr ==
nullptr);
98 Q_ASSERT(m_manager ==
nullptr);
104 g_signal_connect_swapped
105 (manager,
"account-created",
106 G_CALLBACK(&Private::on_account_created), q);
107 g_signal_connect_swapped
108 (manager,
"account-deleted",
109 G_CALLBACK(&Private::on_account_deleted), q);
110 g_signal_connect_swapped
111 (manager,
"account-updated",
112 G_CALLBACK(&Private::on_account_updated), q);
113 g_signal_connect_swapped
114 (manager,
"enabled-event",
115 G_CALLBACK(&Private::on_enabled_event), q);
117 qWarning() << Q_FUNC_INFO <<
"Initializing with NULL AgManager!";
121 void Manager::Private::on_account_created(
Manager *
self, AgAccountId
id)
123 Q_EMIT
self->accountCreated(
id);
126 void Manager::Private::on_account_deleted(
Manager *
self, AgAccountId
id)
128 Q_EMIT
self->accountRemoved(
id);
131 void Manager::Private::on_account_updated(
Manager *
self, AgAccountId
id)
133 Q_EMIT
self->accountUpdated(
id);
136 void Manager::Private::on_enabled_event(
Manager *
self, AgAccountId
id)
138 Q_EMIT
self->enabledEvent(
id);
150 AgManager *manager = ag_manager_new();
152 if (manager !=
nullptr) {
153 d->init(
this, manager);
155 qWarning() <<
"Manager could not be created. DB is locked";
178 ag_manager_new_for_service_type(
serviceType.toUtf8().constData());
180 if (manager !=
nullptr) {
181 d->init(
this, manager);
183 qWarning() <<
"Manager could not be created, DB is locked";
200 GError *error = NULL;
202 (AgManager *)g_initable_new(AG_TYPE_MANAGER, NULL, &error,
203 "use-dbus", !disableNotifications,
205 if (Q_LIKELY(manager)) {
206 d->init(
this, manager);
208 qWarning() <<
"Manager could not be created." << error->message;
209 d->lastError =
Error(error);
219 g_signal_handlers_disconnect_by_func
220 (d->m_manager, (
void *)&Private::on_enabled_event,
this);
221 g_signal_handlers_disconnect_by_func
222 (d->m_manager, (
void *)&Private::on_account_updated,
this);
223 g_signal_handlers_disconnect_by_func
224 (d->m_manager, (
void *)&Private::on_account_deleted,
this);
225 g_signal_handlers_disconnect_by_func
226 (d->m_manager, (
void *)&Private::on_account_created,
this);
227 g_object_unref(d->m_manager);
247 Account *
account = d->m_accounts.value(
id, 0);
271 list = ag_manager_list(d->m_manager);
273 list = ag_manager_list_by_service_type(d->m_manager,
278 AccountIdList idList;
281 for (iter = list; iter; iter = g_list_next(iter))
283 idList.append((AccountId)GPOINTER_TO_INT(iter->data));
286 ag_manager_list_free(list);
305 list = ag_manager_list_enabled(d->m_manager);
307 list = ag_manager_list_enabled_by_service_type(d->m_manager,
312 AccountIdList idList;
315 for (iter = list; iter; iter = g_list_next(iter))
317 idList.append((AccountId)GPOINTER_TO_INT(iter->data));
320 ag_manager_list_free(list);
333 return new Account(
this, providerName,
this);
345 ag_manager_get_service(d->m_manager,
346 serviceName.toUtf8().constData());
365 list = ag_manager_list_services(d->m_manager);
367 list = ag_manager_list_services_by_type(d->m_manager,
372 ServiceList servList;
375 for (iter = list; iter; iter = g_list_next(iter))
377 AgService *
service = (AgService*)iter->data;
397 list = ag_manager_list_services_by_application(d->m_manager,
401 ServiceList servList;
404 for (iter = list; iter; iter = g_list_next(iter))
406 AgService *
service = (AgService*)iter->data;
425 provider = ag_manager_get_provider(d->m_manager,
426 providerName.toUtf8().constData());
439 list = ag_manager_list_providers(d->m_manager);
442 ProviderList provList;
445 for (iter = list; iter; iter = g_list_next(iter))
447 AgProvider *
provider = (AgProvider*)iter->data;
465 type = ag_manager_load_service_type(d->m_manager,
466 name.toUtf8().constData());
479 QByteArray ba = applicationName.toUtf8();
481 ag_manager_get_application(d->m_manager, ba.constData());
494 GList *applications, *list;
496 applications = ag_manager_list_applications_by_service(d->m_manager,
498 for (list = applications; list != NULL; list = list->next) {
499 AgApplication *
application = (AgApplication *)list->data;
502 g_list_free (applications);
513 return UTF8(ag_manager_get_service_type (d->m_manager));
527 ag_manager_set_db_timeout(d->m_manager,
timeout);
536 return ag_manager_get_db_timeout(d->m_manager);
545 ag_manager_set_abort_on_db_timeout(d->m_manager, abort);
554 return ag_manager_get_abort_on_db_timeout(d->m_manager);
562 gboolean useDBus =
true;
563 g_object_get(d->m_manager,
564 "use-dbus", &useDBus,