Example #1
0
static INT_PTR AccListChanged(WPARAM wParam, LPARAM lParam)
{
	PROTOACCOUNT *acc = (PROTOACCOUNT *) lParam;
	if (acc == NULL)
		return 0;

	VoiceProvider *provider = FindModule(acc->szModuleName);

	switch(wParam)
	{
		case PRAC_ADDED:
		{
			AddAccount(acc);
			break;
		}
		case PRAC_CHANGED:
		{
			if (provider != NULL)
				lstrcpyn(provider->description, acc->tszAccountName, MAX_REGS(provider->description));
			break;
		}
		case PRAC_CHECKED:
		{
			BOOL enabled = IsAccountEnabled(acc);

			if (!enabled)
			{
				if (provider != NULL)
					VoiceUnregister((WPARAM) acc->szModuleName, 0);
			}
			else 
			{
				if (provider == NULL)
					AddAccount(acc);
			}
			break;
		}
		case PRAC_REMOVED:
		{
			if (provider != NULL)
				VoiceUnregister((WPARAM) acc->szModuleName, 0);
			break;
		}
	}

	return 0;
}
	void AccountsTab::on_Add__released ()
	{
		AccountPropsDialog dia (this);
		if (dia.exec () != QDialog::Accepted)
			return;

		auto acc = dia.GetAccount ();
		AccsManager_->AddAccount (acc);
		AddAccount (acc);
	}
Example #3
0
bool AccountMgr::LoadAccount(string Name)
{
	QueryResult * result = sLogonSQL->Query("SELECT acct, login, password, gm, flags, banned FROM account_database WHERE login='******'", Name.c_str());
	if(result == 0)
		return false;

	AddAccount(result->Fetch());
	delete result;

	return true;
}
	void PicasaService::ReadAccounts ()
	{
		QSettings settings (QCoreApplication::organizationName (),
				QCoreApplication::applicationName () + "_Blasq_Vangog");
		settings.beginGroup ("Accounts");
		for (const auto& key : settings.childKeys ())
		{
			const auto& serialized = settings.value (key).toByteArray ();
			if (auto acc = PicasaAccount::Deserialize (serialized, this, Proxy_))
				AddAccount (acc);
		}
		settings.endGroup ();
	}
Example #5
0
			void AccountsListDialog::handleAccountAdded (QObject *accObj)
			{
				Plugins::IAccount *acc = qobject_cast<Plugins::IAccount*> (accObj);
				if (!acc)
				{
					qWarning () << Q_FUNC_INFO
							<< accObj
							<< "doesn't implement IAccount, got from"
							<< sender ();
					return;
				}

				AddAccount (acc);
			}
	AccountsTab::AccountsTab (const TabClassInfo& tc, QObject *plugin)
	: AccsManager_ (Core::Instance ().GetAccsManager ())
	, TC_ (tc)
	, ParentPlugin_ (plugin)
	, AccsModel_ (new QStandardItemModel (this))
	{
		AccsModel_->setHorizontalHeaderLabels ({ tr ("Account"), tr ("Type"), tr ("Currency") });

		Ui_.setupUi (this);
		Ui_.AccountsView_->setModel (AccsModel_);

		for (const auto& acc : AccsManager_->GetAccounts ())
			AddAccount (acc);
	}
Example #7
0
// Called when all the modules are loaded
static INT_PTR ModulesLoaded(WPARAM wParam, LPARAM lParam) 
{
	// add our modules to the KnownModules list
	CallService("DBEditorpp/RegisterSingleModule", (WPARAM) MODULE_NAME, 0);

	if (ServiceExists(MS_MC_GETPROTOCOLNAME))
		metacontacts_proto = (char *) CallService(MS_MC_GETPROTOCOLNAME, 0, 0);

    // updater plugin support
    if(ServiceExists(MS_UPDATE_REGISTER))
	{
		Update upd = {0};
		char szCurrentVersion[30];

		upd.cbSize = sizeof(upd);
		upd.szComponentName = pluginInfo.shortName;

		upd.szUpdateURL = UPDATER_AUTOREGISTER;

		upd.szBetaVersionURL = "http://pescuma.org/miranda/voiceservice_version.txt";
		upd.szBetaChangelogURL = "http://pescuma.org/miranda/voiceservice#Changelog";
		upd.pbBetaVersionPrefix = (BYTE *)"Voice Service ";
		upd.cpbBetaVersionPrefix = strlen((char *)upd.pbBetaVersionPrefix);
#ifdef UNICODE
		upd.szBetaUpdateURL = "http://pescuma.org/miranda/voiceserviceW.zip";
#else
		upd.szBetaUpdateURL = "http://pescuma.org/miranda/voiceservice.zip";
#endif

		upd.pbVersion = (BYTE *)CreateVersionStringPlugin((PLUGININFO*) &pluginInfo, szCurrentVersion);
		upd.cpbVersion = strlen((char *)upd.pbVersion);

        CallService(MS_UPDATE_REGISTER, 0, (LPARAM)&upd);
	}

	// Init icons
	{
		IcoLib_Register(mainIcons[0], _T("Voice Calls"), _T("Main"), IDI_MAIN);
		IcoLib_Register(mainIcons[1], _T("Voice Calls"), _T("Dialpad"), IDI_DIALPAD);
		IcoLib_Register(mainIcons[2], _T("Voice Calls"), _T("Secure Overlay"), IDI_SECURE);

		int i;
		for(i = 0; i < MAX_REGS(stateNames); i++)
			IcoLib_Register(stateIcons[i], _T("Voice Calls"), stateNames[i], IDI_TALKING + i);

		for(i = 0; i < MAX_REGS(actionNames); i++)
			IcoLib_Register(actionIcons[i], _T("Voice Calls"), actionNames[i], IDI_ACTION_CALL + i);

		hHooks.push_back( HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged) );
	}

	// Init fonts
	{
		FontIDT fi = {0};
		fi.cbSize = sizeof(fi);
		lstrcpyn(fi.group, TranslateT("Voice Calls"), MAX_REGS(fi.group));
		strncpy(fi.dbSettingsGroup, MODULE_NAME, MAX_REGS(fi.dbSettingsGroup));

		for (int i = 0; i < NUM_FONTS; i++)
		{
			fi.order = i;
			lstrcpyn(fi.name, stateNames[i], MAX_REGS(fi.name));
			strncpy(fi.prefix, stateIcons[i], MAX_REGS(fi.prefix));

			CallService(MS_FONT_REGISTERT, (WPARAM) &fi, 0);
		}

		ReloadFont(0,0);
		hHooks.push_back( HookEvent(ME_FONT_RELOAD, ReloadFont) );
	}

	// Init bkg color
	{
		ColourIDT ci = {0};
		ci.cbSize = sizeof(ci);
		lstrcpyn(ci.group, TranslateT("Voice Calls"), MAX_REGS(ci.group));
		lstrcpyn(ci.name, TranslateT("Background"), MAX_REGS(ci.name));
		strncpy(ci.dbSettingsGroup, MODULE_NAME, MAX_REGS(ci.dbSettingsGroup));
		strncpy(ci.setting, "BkgColor", MAX_REGS(ci.setting));
		ci.defcolour = GetSysColor(COLOR_BTNFACE);

		CallService(MS_COLOUR_REGISTERT, (WPARAM) &ci, 0);

		ReloadColor(0,0);
		hHooks.push_back( HookEvent(ME_COLOUR_RELOAD, ReloadColor) );
	}

	// Init history
	if (ServiceExists(MS_HISTORYEVENTS_REGISTER))
	{
		char *templates[] = {
			"Talking\nCall from %number% has started\n%number%\tOther side of the call",
			"Ringing\nCall from %number% is ringing\n%number%\tOther side of the call",
			"Calling\nCalling %number%\n%number%\tOther side of the call",
			"On Hold\nCall from %number% is on hold\n%number%\tOther side of the call",
			"Ended\nCall from %number% has ended\n%number%\tOther side of the call",
			"Busy\n%number% is busy\n%number%\tOther side of the call",
		};

		HISTORY_EVENT_HANDLER heh = {0};
		heh.cbSize = sizeof(heh);
		heh.module = MODULE_NAME;
		heh.name = "VoiceCall";
		heh.description = "Voice calls";
		heh.eventType = EVENTTYPE_VOICE_CALL;
		heh.defaultIconName = "vca_call";
		heh.supports = HISTORYEVENTS_FORMAT_TCHAR;
		heh.flags = HISTORYEVENTS_FLAG_SHOW_IM_SRMM 
					| HISTORYEVENTS_FLAG_USE_SENT_FLAG
					| HISTORYEVENTS_REGISTERED_IN_ICOLIB;
		heh.templates = templates;
		heh.numTemplates = MAX_REGS(templates);
		CallService(MS_HISTORYEVENTS_REGISTER, (WPARAM) &heh, 0);
	}

	InitOptions();
	InitFrames();

	// Add menu items
	CLISTMENUITEM mi = {0};
	mi.cbSize = sizeof(mi);
	mi.position = -2000020000;
	mi.flags = CMIF_TCHAR;

	HICON icons[MAX_REGS(actionIcons)];
	for(int i = 0; i < MAX_REGS(actionIcons); ++i)
		icons[i] = IcoLib_LoadIcon(actionIcons[i]);

	CreateServiceFunction(MS_VOICESERVICE_CM_CALL, Service_Call);
	mi.ptszName = actionNames[ACTION_CALL];
	mi.hIcon = icons[ACTION_CALL];
	mi.pszService = MS_VOICESERVICE_CM_CALL;
	hCMCall = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi);

	CreateServiceFunction(MS_VOICESERVICE_CM_ANSWER, CMAnswer);
	mi.position++;
	mi.ptszName = actionNames[ACTION_ANSWER];
	mi.hIcon = icons[ACTION_ANSWER];
	mi.pszService = MS_VOICESERVICE_CM_ANSWER;
	hCMAnswer = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi);

	CreateServiceFunction(MS_VOICESERVICE_CM_HOLD, CMHold);
	mi.position++;
	mi.position++;
	mi.ptszName = actionNames[ACTION_HOLD];
	mi.hIcon = icons[ACTION_HOLD];
	mi.pszService = MS_VOICESERVICE_CM_HOLD;
	hCMHold = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi);

	CreateServiceFunction(MS_VOICESERVICE_CM_DROP, CMDrop);
	mi.position++;
	mi.ptszName = actionNames[ACTION_DROP];
	mi.hIcon = icons[ACTION_DROP];
	mi.pszService = MS_VOICESERVICE_CM_DROP;
	hCMDrop = (HANDLE) CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM) &mi);

	for(i = 0; i < MAX_REGS(actionIcons); ++i)
		IcoLib_ReleaseIcon(icons[i]);

	hHooks.push_back( HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu) );

	// Util services
	CreateServiceFunction(MS_VOICESERVICE_CALL, Service_Call);
	CreateServiceFunction(MS_VOICESERVICE_CAN_CALL, Service_CanCall);

	// Sounds
	SKINSOUNDDESCEX ssd = {0};
	ssd.cbSize = sizeof(ssd);
	ssd.pszSection = "Voice Calls";

	{
		for(int i = 0; i < MAX_REGS(sounds); ++i)
		{
			ssd.pszName = sounds[i].name;
			ssd.pszDescription = sounds[i].description;
			CallService(MS_SKIN_ADDNEWSOUND, 0, (LPARAM)&ssd);
		}
	}

	SetTimer(NULL, 0, 1000, ClearOldVoiceCalls);

	// Accounts
	int numAccounts;
	PROTOACCOUNT **accounts;
	ProtoEnumAccounts(&numAccounts, &accounts);
	for(i = 0; i < numAccounts; ++i)
		AddAccount(accounts[i]);

	hHooks.push_back( HookEvent(ME_PROTO_ACCLISTCHANGED, AccListChanged) );

	return 0;
}
Example #8
0
void AccountMgr::ReloadAccounts(bool silent)
{
	setBusy.Acquire();
	if(!silent) sLog.outString("[AccountMgr] Reloading Accounts...");

	// Load *all* accounts.
	QueryResult * result = sLogonSQL->Query("SELECT acct, login, password, gm, flags, banned, forceLanguage, muted FROM accounts");
	Field * field;
	string AccountName;
	set<string> account_list;
	Account * acct;

	if(result)
	{
		do 
		{
			field = result->Fetch();
			AccountName = field[1].GetString();

			// transform to uppercase
			HEARTHSTONE_TOUPPER(AccountName);

			//Use private __GetAccount, for locks
			acct = __GetAccount(AccountName);
			if(acct == 0)
			{
				// New account.
				AddAccount(field);
			}
			else
			{
				// Update the account with possible changed details.
				UpdateAccount(acct, field);
			}

			// add to our "known" list
			account_list.insert(AccountName);

		} while(result->NextRow());
		delete result;
	}

	// check for any purged/deleted accounts
#ifdef WIN32
	HM_NAMESPACE::hash_map<string, Account*>::iterator itr = AccountDatabase.begin();
	HM_NAMESPACE::hash_map<string, Account*>::iterator it2;
#else
	std::map<string, Account*>::iterator itr = AccountDatabase.begin();
	std::map<string, Account*>::iterator it2;
#endif

	for(; itr != AccountDatabase.end();)
	{
		it2 = itr;
		++itr;

		if(account_list.find(it2->first) == account_list.end())
		{
			delete it2->second;
			AccountDatabase.erase(it2);
		}
		else
		{
			it2->second->UsernamePtr = (std::string*)&it2->first;
		}
	}

	if(!silent) sLog.outString("[AccountMgr] Found %u accounts.", AccountDatabase.size());
	setBusy.Release();

	IPBanner::getSingleton().Reload();
}
	void PicasaService::handleAuthSuccess (QObject *accObj)
	{
		auto acc (qobject_cast<PicasaAccount*> (accObj));
		AddAccount (acc);
		saveAccount (acc);
	}
Example #10
0
	void Storage::addMessage (const QVariantMap& data)
	{
		Util::DBLock lock (*DB_);
		try
		{
			lock.Init ();
		}
		catch (const std::exception& e)
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to start transaction:"
					<< e.what ();
			return;
		}

		const QString& entryID = data ["EntryID"].toString ();

		if (!Users_.contains (entryID))
		{
			try
			{
				AddUser (entryID);
			}
			catch (const std::exception& e)
			{
				qWarning () << Q_FUNC_INFO
						<< entryID
						<< "unable to add the user to the DB:"
						<< e.what ();
				return;
			}
		}

		EntryCacheSetter_.bindValue (":id", Users_ [entryID]);
		EntryCacheSetter_.bindValue (":visible_name", data ["VisibleName"]);
		if (!EntryCacheSetter_.exec ())
			Util::DBLock::DumpError (EntryCacheSetter_);

		const QString& accountID = data ["AccountID"].toString ();
		if (!Accounts_.contains (accountID))
		{
			try
			{
				AddAccount (accountID);
			}
			catch (const std::exception& e)
			{
				qWarning () << Q_FUNC_INFO
						<< accountID
						<< "unable to add account ID to the DB:"
						<< e.what ();
				return;
			}
		}

		MessageDumper_.bindValue (":id", Users_ [entryID]);
		MessageDumper_.bindValue (":account_id", Accounts_ [accountID]);
		MessageDumper_.bindValue (":date", data ["DateTime"]);
		MessageDumper_.bindValue (":direction", data ["Direction"]);
		MessageDumper_.bindValue (":message", data ["Body"]);
		MessageDumper_.bindValue (":variant", data ["OtherVariant"]);

		switch (data ["MessageType"].toInt ())
		{
		case IMessage::MTChatMessage:
			MessageDumper_.bindValue (":type", "CHAT");
			break;
		case IMessage::MTMUCMessage:
			MessageDumper_.bindValue (":type", "MUC");
			break;
		case IMessage::MTStatusMessage:
			MessageDumper_.bindValue (":type", "STATUS");
			break;
		case IMessage::MTEventMessage:
			MessageDumper_.bindValue (":type", "EVENT");
			break;
		case IMessage::MTServiceMessage:
			MessageDumper_.bindValue (":type", "SERVICE");
			break;
		}

		if (!MessageDumper_.exec ())
		{
			Util::DBLock::DumpError (MessageDumper_);
			return;
		}

		lock.Good ();
	}