libpurple/plugins/kwallet/purplekwallet.cpp

changeset 42146
f63bd4f70ce9
parent 42138
7b233c733ea9
child 42373
7f7617773171
equal deleted inserted replaced
42145:f9b76a91e3ae 42146:f63bd4f70ce9
22 #include <glib.h> 22 #include <glib.h>
23 #include <glib/gi18n-lib.h> 23 #include <glib/gi18n-lib.h>
24 24
25 #include <purple.h> 25 #include <purple.h>
26 26
27 #include <QCoreApplication> 27 #include <QGuiApplication>
28 28
29 #include <kwallet.h> 29 #include <kwallet.h>
30 30
31 #include "purplekwallet.h" 31 #include "purplekwallet.h"
32 32
33 /****************************************************************************** 33 /******************************************************************************
34 * Globals 34 * Globals
35 *****************************************************************************/ 35 *****************************************************************************/
36 static QCoreApplication *qCoreApp = NULL; 36 static QGuiApplication *guiApp = NULL;
37 static PurpleCredentialProvider *instance = NULL; 37 static PurpleCredentialProvider *instance = NULL;
38 static char *argv[] = {
39 (char*)"purplekwallet",
40 };
41 static int argc = G_N_ELEMENTS(argv);
38 42
39 #define PURPLE_KWALLET_DOMAIN (g_quark_from_static_string("purple-kwallet")) 43 #define PURPLE_KWALLET_DOMAIN (g_quark_from_static_string("purple-kwallet"))
40 #define PURPLE_KWALLET_WALLET_NAME (KWallet::Wallet::NetworkWallet()) 44 #define PURPLE_KWALLET_WALLET_NAME (KWallet::Wallet::NetworkWallet())
41 45
42 struct _PurpleKWalletProvider { 46 struct _PurpleKWalletProvider {
567 kwallet_load(GPluginPlugin *plugin, GError **error) { 571 kwallet_load(GPluginPlugin *plugin, GError **error) {
568 PurpleCredentialManager *manager = NULL; 572 PurpleCredentialManager *manager = NULL;
569 573
570 purple_kwallet_provider_register_type(G_TYPE_MODULE(plugin)); 574 purple_kwallet_provider_register_type(G_TYPE_MODULE(plugin));
571 575
572 if(qCoreApp == NULL) { 576 if(guiApp == NULL) {
573 int argc = 0; 577 guiApp = new QGuiApplication(argc, argv);
574 qCoreApp = new QCoreApplication(argc, NULL); 578 guiApp->setApplicationName(purple_kwallet_get_ui_name());
575 qCoreApp->setApplicationName(purple_kwallet_get_ui_name());
576 } 579 }
577 580
578 if(!KWallet::Wallet::isEnabled()) { 581 if(!KWallet::Wallet::isEnabled()) {
579 g_set_error(error, PURPLE_KWALLET_DOMAIN, 0, 582 g_set_error(error, PURPLE_KWALLET_DOMAIN, 0,
580 "KWallet service is disabled."); 583 "KWallet service is disabled.");
602 605
603 if(!ret) { 606 if(!ret) {
604 return ret; 607 return ret;
605 } 608 }
606 609
607 if(qCoreApp != NULL) { 610 if(guiApp != NULL) {
608 delete qCoreApp; 611 delete guiApp;
609 qCoreApp = NULL; 612 guiApp = NULL;
610 } 613 }
611 614
612 g_clear_object(&instance); 615 g_clear_object(&instance);
613 616
614 return TRUE; 617 return TRUE;

mercurial