Пример #1
0
ROWCELL *cppInitModernRow(ROWCELL	** tabAccess)
{
	int fsize;
	int seq = 0;
	ROWCELL * RowRoot = NULL;
	FILE * hFile;
	int i=0;
	if (!db_get_b(NULL,"ModernData","UseAdvancedRowLayout",SETTING_ROW_ADVANCEDLAYOUT_DEFAULT)) return NULL;
	tmplbuf = NULL;
	if ( db_get_b(NULL,"ModernData","UseAdvancedRowLayout",SETTING_ROW_ADVANCEDLAYOUT_DEFAULT) == 1)
		tmplbuf = db_get_sa(NULL,"ModernData","RowTemplate");
	if (tmplbuf) {
		rowParse(RowRoot, RowRoot, tmplbuf, i, seq,tabAccess);
		mir_free(tmplbuf);
		return RowRoot;
	}
	if (hFile = fopen("template.txt", "rb"))
	{
		fsize = _filelength(_fileno(hFile));
		tmplbuf = (char*)malloc(fsize+1);
		ZeroMemory(tmplbuf, fsize+1);

		for (i=0; i < fsize; i++) tmplbuf[i] = getc(hFile);
		tmplbuf[i] = 0;
		i=0;
		rowParse(RowRoot, RowRoot, tmplbuf, i, seq,tabAccess);
		db_set_s(NULL,"ModernData","RowTemplate",tmplbuf);
		free(tmplbuf);
		fclose(hFile);
		return RowRoot;
	}
	return NULL;

}
Пример #2
0
// do lastchecked(file(X)) returns amount of chars to add to str pointer
int lastChecked(CMStringA &szNewStr, const char *str)
{
	char *szPattern = "lastchecked(file(";
	size_t cbPattern = mir_strlen(szPattern);

	if (!strncmp(str, szPattern, cbPattern)) {
		int file;
		char tszFileName[MAX_PATH], temp[MAX_PATH], szSetting[20];
		sscanf(&str[cbPattern], "%d", &file);
		mir_snprintf(szSetting, "fn%d", file);

		char *szVar = db_get_sa(NULL, MODNAME, szSetting);
		if (szVar == NULL)
			return 0;

		if (!strncmp("http://", szVar, 7) || !strncmp("https://", szVar, 8))
			mir_snprintf(tszFileName, _countof(tszFileName), "%s\\plugins\\fn%d.html", getMimDir(temp), file);
		else
			mir_strncpy(tszFileName, szVar, _countof(tszFileName));
		mir_free(szVar);

		HANDLE hFile = CreateFileA(tszFileName, 0, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
		if (hFile == INVALID_HANDLE_VALUE)
			return 0;

		if (GetLastWriteTime(hFile, tszFileName)) {
			CloseHandle(hFile);
			szNewStr.Append(tszFileName);
			mir_snprintf(tszFileName, _countof(tszFileName), "%s%d))", szPattern, file);
			return (int)mir_strlen(tszFileName);
		}
		CloseHandle(hFile);
	}
	return 0;
}
Пример #3
0
int readFileIntoArray(int fileNumber, char *FileContents[])
{
	char dbSetting[20], temp[MAX_STRING_LENGTH];
	mir_snprintf(dbSetting, _countof(dbSetting), "fn%d", fileNumber);

	char *szVar = db_get_sa(NULL, MODNAME, dbSetting);
	if (szVar == NULL)
		return 0;

	char tszFileName[MAX_PATH];
	if (!strncmp("http://", szVar, 7) || !strncmp("https://", szVar, 7))
		mir_snprintf(tszFileName, _countof(tszFileName), "%s\\plugins\\fn%d.html", getMimDir(temp), fileNumber);
	else
		mir_strncpy(tszFileName, szVar, _countof(tszFileName));
	mir_free(szVar);

	FILE* file = fopen(tszFileName, "r");
	if (file == NULL)
		return 0;

	// read the file into the FileContents array
	// free this array before stringReplacer() returns
	int i;
	for (i = 0; fgets(temp, MAX_STRING_LENGTH - 1, file); i++) {
		if (temp[mir_strlen(temp) - 1] == '\n')
			temp[mir_strlen(temp) - 1] = '\0';
		else temp[mir_strlen(temp)] = '\0';

		FileContents[i] = (char*)malloc(mir_strlen(temp) + 1);
		if (FileContents[i] == NULL) break;
		mir_strcpy(FileContents[i], temp);
	}
	fclose(file);
	return i;
}
Пример #4
0
static int DefaultOnClick(WPARAM hContact, LPARAM lParam, LPARAM param)
{
	Info *p = (Info*)param;
	if (p == NULL)
		return 0;

	if (hContact == NULL)
		return 0;

	char *proto = GetContactProto(hContact);
	if (IsEmpty(proto))
		return 0;

	bool found = false;
	for (int j = 0; !found && j < SIZEOF(p->db); j += 2) {
		if (p->db[j + 1] == NULL)
			break;

		ptrA szValue(db_get_sa(hContact, p->db[j] == NULL ? proto : p->db[j], p->db[j + 1]));
		if (!IsEmpty(szValue)) {
			p->OnClick(p, szValue);
			found = true;
		}
	}

	return 0;
}
Пример #5
0
INT_PTR CSkypeProto::SvcCreateChat(WPARAM, LPARAM)
{
	if (IsOnline())
	{
		CSkypeGCCreateDlg dlg(this);
		if (!dlg.DoModal())
		{
			return 1;
		}
		LIST<char>uids(1);
		for (std::vector<MCONTACT>::size_type i = 0; i < dlg.m_hContacts.size(); i++)
		{
			uids.insert(db_get_sa(dlg.m_hContacts[i], m_szModuleName, SKYPE_SETTINGS_ID));
		}
		uids.insert(getStringA(SKYPE_SETTINGS_ID));

		SendRequest(new CreateChatroomRequest(m_szRegToken, uids, ptrA(getStringA(SKYPE_SETTINGS_ID)), m_szServer));

		for (int i = 0; i < uids.getCount(); i++)
			mir_free(uids[i]);
		uids.destroy();
		return 0;
	}
	return 1;
}
Пример #6
0
void AddSessionMark(MCONTACT hContact, int mode, char bit)
{
	if (mode == 0) {
		ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks"));
		if (szValue) {
			char temp_1 = szValue[0];
			for (int i = 0; i < g_ses_limit; i++) {
				char temp_2 = szValue[i + 1];
				szValue[i + 1] = temp_1;
				temp_1 = temp_2;
			}
			for (int i = g_ses_limit; i < 10; i++)
				szValue[i] = '0';
			szValue[0] = bit;
			db_set_s(hContact, MODNAME, "LastSessionsMarks", szValue);
		}
		else if (bit == '1')
			db_set_s(hContact, MODNAME, "LastSessionsMarks", "10000000000");
	}
	else if (mode == 1) {
		ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsMarks"));
		if (szValue) {
			char *pszBuffer;
			if (mir_strlen(szValue) < g_ses_count) {
				pszBuffer = (char*)mir_alloc(g_ses_count + 1);
				memset(pszBuffer, 0, (g_ses_count + 1));
				mir_strcpy(pszBuffer, szValue);
			}
			else pszBuffer = szValue.detach();

			char temp_1 = pszBuffer[0];
			for (int i = 0; i < g_ses_count; i++) {
				char temp_2 = pszBuffer[i + 1];
				pszBuffer[i + 1] = temp_1;
				temp_1 = temp_2;
			}
			pszBuffer[0] = bit;
			db_set_s(hContact, MODNAME, "UserSessionsMarks", pszBuffer);

			mir_free(pszBuffer);
		}
		else if (bit == '1')
			db_set_s(hContact, MODNAME, "UserSessionsMarks", "10000000000");
		else
			db_set_s(hContact, MODNAME, "UserSessionsMarks", "00000000000");
	}
}
Пример #7
0
void SetSessionMark(MCONTACT hContact, int mode, char bit, unsigned int marknum)
{
	if (mode == 0) {
		ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks"));
		if (szValue) {
			szValue[marknum] = bit;
			db_set_s(hContact, MODNAME, "LastSessionsMarks", szValue);
		}
	}
	else if (mode == 1) {
		ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsMarks"));
		if (szValue) {
			szValue[marknum] = bit;
			db_set_s(hContact, MODNAME, "UserSessionsMarks", szValue);
		}
	}
}
Пример #8
0
int CSkypeProto::OnContactDeleted(MCONTACT hContact, LPARAM)
{
	if (!IsOnline()) return 1;

	if (hContact && !isChatRoom(hContact))
		PushRequest(new DeleteContactRequest(li, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))));
	return 0;
}
Пример #9
0
INT_PTR CSkypeProto::BlockContact(WPARAM hContact, LPARAM)
{
	if (!IsOnline()) return 1;

	if (IDYES == MessageBox(NULL, TranslateT("Are you sure?"), TranslateT("Warning"), MB_YESNO | MB_ICONQUESTION))
		SendRequest(new BlockContactRequest(li, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))), &CSkypeProto::OnBlockContact, (void *)hContact);
	return 0;
}
Пример #10
0
int CSkypeProto::GetInfo(MCONTACT hContact, int)
{
	if (!isChatRoom(hContact))
		PushRequest(
			new GetProfileRequest(li, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))),
			&CSkypeProto::LoadProfile);
	return 0;
}
Пример #11
0
void CDropbox::RequestAccountInfo()
{
	MCONTACT hContact = CDropbox::GetDefaultContact();

	ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
	GetAccountInfoRequest request(token);
	NLHR_PTR response(request.Send(hNetlibConnection));
	HandleHttpResponseError(response);

	JSONNode root = JSONNode::parse(response->pData);
	if (root.empty())
		return;

	JSONNode referral_link = root.at("referral_link");
	if (!referral_link.empty())
		db_set_s(hContact, MODULE, "Homepage", referral_link.as_string().c_str());

	JSONNode display_name = root.at("display_name");
	if (!display_name.empty())
	{
		ptrT display_name(mir_utf8decodeT(display_name.as_string().c_str()));
		TCHAR *sep = _tcsrchr(display_name, _T(' '));
		if (sep)
		{
			db_set_ts(hContact, MODULE, "LastName", sep + 1);
			display_name[mir_tstrlen(display_name) - mir_tstrlen(sep)] = '\0';
			db_set_ts(hContact, MODULE, "FirstName", display_name);
		}
		else
		{
			db_set_ts(hContact, MODULE, "FirstName", display_name);
			db_unset(hContact, MODULE, "LastName");
		}
	}

	JSONNode country = root.at("country");
	if (!country.empty())
	{
		std::string isocode = country.as_string();

		if (isocode.empty())
			db_unset(hContact, MODULE, "Country");
		else
		{
			char *country = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0);
			db_set_s(hContact, MODULE, "Country", country);
		}
	}

	JSONNode quota_info = root.at("quota_info");
	if (!quota_info.empty())
	{
		db_set_dw(hContact, MODULE, "SharedQuota", quota_info.at("shared").as_int());
		db_set_dw(hContact, MODULE, "NormalQuota", quota_info.at("normal").as_int());
		db_set_dw(hContact, MODULE, "TotalQuota", quota_info.at("quota").as_int());
	}
}
Пример #12
0
LPSTR myDBGetStringDecode(MCONTACT hContact, const char *szModule, const char *szSetting)
{
	char *val = db_get_sa(hContact, szModule, szSetting);
	if (!val) return NULL;
	size_t len = strlen(val) + 64;
	char *buf = (LPSTR)mir_alloc(len);
	strncpy(buf, val, len); mir_free(val);
	return buf;
}
Пример #13
0
void LoadWatchedProtos()
{
	ptrA szProtos(db_get_sa(NULL, S_MOD, "WatchedProtocols"));
	if (szProtos == NULL)
		return;

	for (char *p = strtok(szProtos, " "); p != NULL; p = strtok(NULL, " "))
		arWatchedProtos.insert(mir_strdup(p));
}
Пример #14
0
void CDropbox::RequestAccountInfo()
{
	MCONTACT hContact = CDropbox::GetDefaultContact();

	ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
	GetAccountInfoRequest request(token);
	NLHR_PTR response(request.Send(hNetlibConnection));
	HandleHttpResponseError(response);

	JSONNode root = JSONNode::parse(response->pData);
	if (root.empty())
		return;

	JSONNode referral_link = root.at("referral_link");
	if (!referral_link.empty())
		db_set_s(hContact, MODULE, "Homepage", referral_link.as_string().c_str());

	JSONNode display_name = root.at("display_name");
	if (!display_name.empty())
	{
		CMString tszDisplayName(display_name.as_mstring());
		int pos = tszDisplayName.ReverseFind(' ');
		if (pos != -1)
		{
			db_set_ts(hContact, MODULE, "LastName", tszDisplayName.Mid(pos+1));
			db_set_ts(hContact, MODULE, "FirstName", tszDisplayName.Left(pos));
		}
		else
		{
			db_set_ts(hContact, MODULE, "FirstName", tszDisplayName);
			db_unset(hContact, MODULE, "LastName");
		}
	}

	JSONNode country = root.at("country");
	if (!country.empty())
	{
		std::string isocode = country.as_string();

		if (isocode.empty())
			db_unset(hContact, MODULE, "Country");
		else
		{
			char *szCountry = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0);
			db_set_s(hContact, MODULE, "Country", szCountry);
		}
	}

	JSONNode quota_info = root.at("quota_info");
	if (!quota_info.empty())
	{
		db_set_dw(hContact, MODULE, "SharedQuota", quota_info.at("shared").as_int());
		db_set_dw(hContact, MODULE, "NormalQuota", quota_info.at("normal").as_int());
		db_set_dw(hContact, MODULE, "TotalQuota", quota_info.at("quota").as_int());
	}
}
Пример #15
0
int GetInSessionOrder(MCONTACT hContact, int mode, int count)
{
	char szTemp[3];
	if (mode == 0) {
		ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsOrder"));
		if (szValue) {
			strncpy_s(szTemp, &szValue[count * 2], 2);
			return atoi(szTemp);
		}
	}
	else if (mode == 1) {
		ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsOrder"));
		if (szValue) {
			strncpy_s(szTemp, &szValue[count * 2], 2);
			return atoi(szTemp);
		}
	}
	return 0;
}
Пример #16
0
BOOL LoadKeyGPG(pUinKey ptr)
{
	LPSTR key = db_get_sa(ptr->hContact,MODULENAME,"gpg");
	if (key) {
		gpg_set_keyid(ptr->cntx,key);
		mir_free(key);
		return 2;
	}
	return 0;
}
Пример #17
0
void CDropbox::RequestAccountInfo(void *p)
{
	CDropbox *self = (CDropbox*)p;

	MCONTACT hContact = self->GetDefaultContact();

	ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
	GetCurrentAccountRequest request(token);
	NLHR_PTR response(request.Send(self->hNetlibConnection));
	HandleJsonResponseError(response);

	JSONNode root = JSONNode::parse(response->pData);
	if (root.empty())
		return;

	JSONNode referral_link = root.at("referral_link");
	if (!referral_link.empty())
		db_set_s(hContact, MODULE, "Homepage", referral_link.as_string().c_str());

	JSONNode email = root.at("email");
	if (!email.empty())
		db_set_s(hContact, MODULE, "e-mail", email.as_string().c_str());

	JSONNode name = root.at("name");
	if (!name.empty()) {
		db_set_utf(hContact, MODULE, "FirstName", name.at("given_name").as_string().c_str());
		db_set_utf(hContact, MODULE, "LastName", name.at("surname").as_string().c_str());
	}

	JSONNode country = root.at("country");
	if (!country.empty()) {
		std::string isocode = country.as_string();

		if (isocode.empty())
			db_unset(hContact, MODULE, "Country");
		else {
			char *szCountry = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0);
			db_set_s(hContact, MODULE, "Country", szCountry);
		}
	}

	/*JSONNode quota_info = root.at("quota_info");
	if (!quota_info.empty()) {
		ULONG lTotalQuota = quota_info.at("quota").as_int();
		ULONG lNormalQuota = quota_info.at("normal").as_int();
		ULONG lSharedQuota = quota_info.at("shared").as_int();

		db_set_dw(hContact, MODULE, "SharedQuota", lSharedQuota);
		db_set_dw(hContact, MODULE, "NormalQuota", lNormalQuota);
		db_set_dw(hContact, MODULE, "TotalQuota", lTotalQuota);

		db_set_s(hContact, "CList", "StatusMsg", CMStringA(FORMAT, Translate("Free %ld of %ld MB"), (lTotalQuota - lNormalQuota) / (1024 * 1024), lTotalQuota / (1024 * 1024)));
	}*/
}
Пример #18
0
void SetInSessionOrder(MCONTACT hContact, int mode, int count, unsigned int ordernum)
{
	char szTemp[3];
	mir_snprintf(szTemp, "%02u", ordernum);

	if (mode == 0) {
		ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsOrder"));
		if (szValue) {
			szValue[count * 2] = szTemp[0];
			szValue[count * 2 + 1] = szTemp[1];
			db_set_s(hContact, MODNAME, "LastSessionsOrder", szValue);
		}
	}
	else if (mode == 1) {
		ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsOrder"));
		if (szValue) {
			szValue[count * 2] = szTemp[0];
			szValue[count * 2 + 1] = szTemp[1];
			db_set_s(hContact, MODNAME, "UserSessionsOrder", szValue);
		}
	}
}
Пример #19
0
void IcolibExtraIcon::applyIcon(MCONTACT hContact)
{
	if (!isEnabled() || hContact == NULL)
		return;

	HANDLE hImage = INVALID_HANDLE_VALUE;

	ptrA szIconName(db_get_sa(hContact, MODULE_NAME, m_szName));
	if (!IsEmpty(szIconName))
		hImage = GetIcon(szIconName);

	ClistSetExtraIcon(hContact, hImage);
}
Пример #20
0
std::string Quotes_DBGetStringA(MCONTACT hContact, const char* szModule, const char* szSetting, const char* pszDefValue /*= NULL*/)
{
	std::string sResult;
	char* pszSymbol = db_get_sa(hContact, szModule, szSetting);
	if (NULL != pszSymbol) {
		sResult = pszSymbol;
		mir_free(pszSymbol);
	}
	else if (NULL != pszDefValue)
		sResult = pszDefValue;

	return sResult;
}
Пример #21
0
int fnTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount)
{
	if (netProtoCount == 0)
		return cli.pfnTrayIconSetBaseInfo(ImageList_GetIcon(hCListImages, cli.pfnIconFromStatusMode(NULL, averageMode, NULL), ILD_NORMAL), NULL);

	int trayIconSetting = db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT);

	if (averageMode > 0) {
		if (trayIconSetting != SETTING_TRAYICON_MULTI)
			return cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, NULL, averageMode), NULL);

		if (db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))
			return cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoServiceInt(NULL, szChangedProto, PS_GETSTATUS, 0, 0)), (char*)szChangedProto);

		if (cli.trayIcon == NULL || cli.trayIcon[0].szProto == NULL)
			return cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, NULL, averageMode), NULL);

		cli.pfnTrayIconDestroy(cli.hwndContactList);
		cli.pfnTrayIconInit(cli.hwndContactList);
	}
	else {
		switch (trayIconSetting) {
		case SETTING_TRAYICON_CYCLE:
			cli.cycleTimerId = SetTimer(NULL, 0, db_get_w(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 1000, cli.pfnTrayCycleTimerProc);
			return cli.pfnTrayIconSetBaseInfo(ImageList_GetIcon
				(hCListImages, cli.pfnIconFromStatusMode(szChangedProto, CallProtoServiceInt(NULL, szChangedProto, PS_GETSTATUS, 0, 0), NULL),
				ILD_NORMAL), NULL);

		case SETTING_TRAYICON_MULTI:
			if (!cli.trayIcon)
				cli.pfnTrayIconRemove(NULL, NULL);
			else if ((cli.trayIconCount > 1 || netProtoCount == 1) || db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))
				return cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoServiceInt(NULL, szChangedProto, PS_GETSTATUS, 0, 0)), (char*)szChangedProto);
			else {
				cli.pfnTrayIconDestroy(cli.hwndContactList);
				cli.pfnTrayIconInit(cli.hwndContactList);
			}
			break;

		case SETTING_TRAYICON_SINGLE:
			ptrA szProto(db_get_sa(NULL, "CList", "PrimaryStatus"));
			return cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szProto, szProto ?
				CallProtoServiceInt(NULL, szProto, PS_GETSTATUS, 0, 0) :
				CallService(MS_CLIST_GETSTATUSMODE, 0, 0)), szProto);
		}
	}

	return -1;
}
Пример #22
0
void RemoveSessionMark(MCONTACT hContact, int mode, int marknum)
{
	if (mode == 0) {
		ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks"));
		if (szValue) {
			for (int i = marknum; i < g_ses_limit; i++)
				szValue[i] = szValue[i + 1];

			for (int i = g_ses_limit; i < 10; i++)
				szValue[i] = '0';

			db_set_s(hContact, MODNAME, "LastSessionsMarks", szValue);
		}
	}
	else if (mode == 1) {
		ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsMarks"));
		if (szValue) {
			for (int i = marknum; i < g_ses_limit; i++)
				szValue[i] = szValue[i + 1];

			db_set_s(hContact, MODNAME, "UserSessionsMarks", szValue);
		}
	}
}
Пример #23
0
int CVkProto::OnDbEventRead(WPARAM, LPARAM hDbEvent)
{
	debugLogA("CVkProto::OnDbEventRead");
	MCONTACT hContact = db_event_getContact(hDbEvent);
	if (!hContact)
		return 0;

	CMStringA szProto(ptrA(db_get_sa(hContact, "Protocol", "p")));
	if (szProto.IsEmpty() || szProto != m_szModuleName)
		return 0;

	if (m_vkOptions.iMarkMessageReadOn == MarkMsgReadOn::markOnRead)
		MarkMessagesRead(hContact);
	return 0;
}
Пример #24
0
void loadSupportedProtocols()
{
	LPSTR szNames = db_get_sa(0,MODULENAME,"protos");
	if (szNames && strchr(szNames,':') == NULL) {
		LPSTR tmp = (LPSTR) mir_alloc(2048); int j=0;
		for (int i=0; szNames[i]; i++) {
			if (szNames[i] == ';')
				memcpy((PVOID)(tmp+j),(PVOID)":1:0:0",6); j+=6;

			tmp[j++] = szNames[i];
		}
		tmp[j] = '\0';
		SAFE_FREE(szNames); szNames = tmp;
		db_set_s(0,MODULENAME,"protos",szNames);
	}

	int numberOfProtocols;
	PROTOACCOUNT **protos;
	ProtoEnumAccounts(&numberOfProtocols, &protos);

	for (int i=0; i < numberOfProtocols; i++) {
		if (!protos[i]->szModuleName || !CallProtoService(protos[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0))
			continue;

		SupPro *p = (SupPro*)mir_calloc(sizeof(SupPro));
		p->name = mir_strdup(protos[i]->szModuleName);
		if (szNames && p->name) {
			char tmp[128]; strcpy(tmp, p->name); strcat(tmp,":");
			LPSTR szName = strstr(szNames, tmp);
			if (szName) {
				szName = strchr(szName,':');
				if (szName) {
					p->inspecting = (*++szName == '1');
					szName = strchr(szName,':');
					if (szName) {
						p->split_on = atoi(++szName); p->tsplit_on = p->split_on;
						szName = strchr(szName,':');
						if (szName)
							p->split_off = atoi(++szName); p->tsplit_off = p->split_off;
					}
				}
			}
		}
		else p->inspecting = true;
		arProto.insert(p);
	}
	SAFE_FREE(szNames);
}
Пример #25
0
void SettingsMigrate(void)
{
	BYTE TrayIcon = db_get_b(NULL, "CList", "TrayIcon", 0);
	BYTE AlwaysPrimary = db_get_b(NULL, "CList", "AlwaysPrimary", 0);
	BYTE AlwaysMulti = db_get_b(NULL, "CList", "AlwaysMulti", 0);
	ptrA PrimaryStatus(db_get_sa(NULL, "CList", "PrimaryStatus"));

	// these strings must always be set
	if (PrimaryStatus) {
		db_set_s(NULL, "CList", "tiAccS", PrimaryStatus);
		db_set_s(NULL, "CList", "tiAccV", PrimaryStatus);
	}
	else {
		db_set_s(NULL, "CList", "tiAccS", "");
		db_set_s(NULL, "CList", "tiAccV", "");
	}

	switch (TrayIcon) {
	case 0: // global or single acc
		if (AlwaysPrimary) {
			if (!PrimaryStatus) { // global always
				db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_GLOBAL);
				db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_GLOBAL);
			}
			else { // single acc always
				db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_ACC);
				db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_ACC);
			}
		}
		else {
			db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_GLOBAL);
			db_set_b(NULL, "CList", "tiModeV", (PrimaryStatus) ? TRAY_ICON_MODE_ACC : TRAY_ICON_MODE_GLOBAL);
		}
		break;

	case 1: // cycle
		db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_CYCLE);
		db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_CYCLE);
		break;

	case 2: // multiple
		db_set_b(NULL, "CList", "tiModeS", (AlwaysMulti) ? TRAY_ICON_MODE_ALL : TRAY_ICON_MODE_GLOBAL);
		db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_ALL);
		break;
	}
}
Пример #26
0
void CDropbox::CommandContent(void *arg)
{
	CommandParam *param = (CommandParam*)arg;

	char *path = (char*)param->data;
	if (path == NULL)
		path = "";

	ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
	ptrA encodedPath(mir_utf8encode(path));
	GetMetadataRequest request(token, encodedPath);
	NLHR_PTR response(request.Send(param->instance->hNetlibConnection));

	if (response == NULL || response->resultCode != HTTP_STATUS_OK) {
		ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
		return;
	}

	JSONNode root = JSONNode::parse(response->pData);
	if (root.empty()) {
		ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hProcess, 0);
		return;
	}

	CMStringA message;
	bool isDir = root.at("is_dir").as_bool();
	if (!isDir)
		message.AppendFormat("\"%s\" %s", encodedPath, T2Utf(TranslateT("is file")));
	else {
		JSONNode content = root.at("contents").as_array();
		for (size_t i = 0; i < content.size(); i++) {
			JSONNode item = content[i];
			if (item.empty()) {
				if (i == 0)
					message.AppendFormat("\"%s\" %s", encodedPath, T2Utf(TranslateT("is empty")));
				break;
			}

			CMStringA subName(item.at("path").as_string().c_str());
			message.AppendFormat("%s\n", (subName[0] == '/') ? subName.Mid(1) : subName);
		}
	}

	ProtoBroadcastAck(MODULE, param->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, param->hProcess, 0);
	CallContactService(param->instance->GetDefaultContact(), PSR_MESSAGE, 0, (LPARAM)message.GetBuffer());
}
Пример #27
0
void MinecraftDynmapProto::SignOnWorker(void*)
{
	SYSTEMTIME t;
	GetLocalTime(&t);
	debugLogA("[%d.%d.%d] Using Omegle Protocol %s", t.wDay, t.wMonth, t.wYear, __VERSION_STRING_DOTS);

	ScopedLock s(signon_lock_);

	int old_status = m_iStatus;

	// Load server from database
	ptrA str(db_get_sa(NULL, m_szModuleName, MINECRAFTDYNMAP_KEY_SERVER));
	if (!str || !str[0]) {
		MessageBox(NULL, TranslateT("Set server address to connect."), m_tszUserName, MB_OK);
		SetStatus(ID_STATUS_OFFLINE);
		return;
	}
	m_server = str;

	// Fix format of given server
	if (m_server.substr(0, 7) != "http://" && m_server.substr(0, 8) != "https://")
		m_server = "http://" + m_server;
	if (m_server.substr(m_server.length() - 1, 1) == "/")
		m_server = m_server.substr(0, m_server.length() -1);

	if (doSignOn()) {
		// Signed in, switch to online, create chatroom and start events loop
		m_iStatus = m_iDesiredStatus;
		ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);

		setDword("LogonTS", (DWORD)time(NULL));
		ClearChat();
		OnJoinChat(0, false);

		ResetEvent(events_loop_event_);

		ForkThread(&MinecraftDynmapProto::EventsLoop, this);
	}
	else {
		// Some error
		ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_FAILED, (HANDLE)old_status, m_iStatus);
	}

}
Пример #28
0
static INT_PTR GoToURLMsgCommand(WPARAM wParam, LPARAM lParam)
{
	ptrA szMsg(db_get_sa(wParam, "CList", "StatusMsg"));

	char *szURL = StrFindURL(szMsg);
	if (szURL != NULL) {
		int i;
		for (i = 0; szURL[i] != ' ' && szURL[i] != '\n' && szURL[i] != '\r' && szURL[i] != '\t' && szURL[i] != '\0'; i++);

		char *szMsgURL = (char *)mir_alloc(i + 1);
		if (szMsgURL) {
			mir_strncpy(szMsgURL, szURL, i + 1);
			Utils_OpenUrl(szMsgURL);
			mir_free(szMsgURL);
		}
	}

	return 0;
}
Пример #29
0
void CSkypeGCCreateDlg::btnOk_OnOk(CCtrlButton*)
{
	for (MCONTACT hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) 
	{
		if (!m_proto->isChatRoom(hContact))
		{
			if (HANDLE hItem = m_clc.FindContact(hContact)) 
			{
				if (m_clc.GetCheck(hItem)) 
				{
					char *szName = db_get_sa(hContact, m_proto->m_szModuleName, SKYPE_SETTINGS_ID);
					if (szName != NULL)
						m_ContactsList.insert(szName);
				}
			}
		}
	}
	m_ContactsList.insert(m_proto->li.szSkypename);
	EndDialog(m_hwnd, m_ContactsList.getCount());
}
Пример #30
0
// store KeyB into context
int InitKeyB(pUinKey ptr,LPCSTR key)
{
	Sent_NetLog("InitKeyB: %s", key);

	if (!ptr->cntx)
		ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0);

	if (!cpp_keyp(ptr->cntx)) {
		char *tmp = db_get_sa(ptr->hContact,MODULENAME,"PSK");
		if (tmp) {
		    cpp_init_keyp(ptr->cntx,tmp);	// make pre-shared key from password
		    mir_free(tmp);
		}
	}

	cpp_init_keyb(ptr->cntx,key);
	ptr->features = cpp_get_features(ptr->cntx);

	return cpp_get_error(ptr->cntx);
}