Beispiel #1
0
void TwitterProto::ShowContactPopup(HANDLE hContact,const std::string &text)
{
	if(!ServiceExists(MS_POPUP_ADDPOPUPT) || db_get_b(0,m_szModuleName,TWITTER_KEY_POPUP_SHOW,0) == 0)
	{
		return;
	}

	POPUPDATAT popup = {};
	popup.lchContact = hContact;
	popup.iSeconds = db_get_dw(0,m_szModuleName,TWITTER_KEY_POPUP_TIMEOUT,0);
	
	popup.colorBack = db_get_dw(0,m_szModuleName,TWITTER_KEY_POPUP_COLBACK,0);
	if(popup.colorBack == 0xFFFFFFFF)
		popup.colorBack = GetSysColor(COLOR_WINDOW);
	popup.colorText = db_get_dw(0,m_szModuleName,TWITTER_KEY_POPUP_COLTEXT,0);
	if(popup.colorBack == 0xFFFFFFFF)
		popup.colorBack = GetSysColor(COLOR_WINDOWTEXT);

	DBVARIANT dbv;
	if( !db_get_ts(hContact,"CList","MyHandle",&dbv) || !db_get_ts(hContact,m_szModuleName,TWITTER_KEY_UN,&dbv))
	{
		_tcsncpy(popup.lptzContactName,dbv.ptszVal,MAX_CONTACTNAME);
		db_free(&dbv);
	}

	mbcs_to_tcs(CP_UTF8,text.c_str(),popup.lptzText,MAX_SECONDLINE);
	PUAddPopupT(&popup);
}
Beispiel #2
0
void loadDBSettings(plgsettings *ps)
{
	logmsg("loadDBSettings");

	ps->align=db_get_b(NULL,THIS_MODULE, "align", DEFAULT_ALIGN);
	ps->salign=db_get_b(NULL,THIS_MODULE, "salign", DEFAULT_SALIGN);
	ps->altShadow=db_get_b(NULL,THIS_MODULE, "altShadow", DEFAULT_ALTSHADOW);
	ps->transparent=db_get_b(NULL,THIS_MODULE, "transparent", DEFAULT_TRANPARENT);
	ps->showShadow=db_get_b(NULL,THIS_MODULE, "showShadow", DEFAULT_SHOWSHADOW);
	ps->messages=db_get_b(NULL,THIS_MODULE, "messages", DEFAULT_ANNOUNCEMESSAGES);
	ps->a_user=db_get_b(NULL,THIS_MODULE, "a_user", DEFAULT_ANNOUNCESTATUS);
	ps->distance=db_get_b(NULL,THIS_MODULE, "distance", DEFAULT_DISTANCE);
	ps->winx=db_get_dw(NULL,THIS_MODULE, "winx", DEFAULT_WINX);
	ps->winy=db_get_dw(NULL,THIS_MODULE, "winy", DEFAULT_WINY);
	ps->winxpos=db_get_dw(NULL,THIS_MODULE, "winxpos", DEFAULT_WINXPOS);
	ps->winypos=db_get_dw(NULL,THIS_MODULE, "winypos", DEFAULT_WINYPOS);
	ps->alpha=db_get_b(NULL,THIS_MODULE, "alpha", DEFAULT_ALPHA);
	ps->showmystatus=db_get_b(NULL,THIS_MODULE, "showMyStatus", DEFAULT_SHOWMYSTATUS);
	ps->timeout=db_get_dw(NULL,THIS_MODULE, "timeout", DEFAULT_TIMEOUT);
	ps->clr_msg=db_get_dw(NULL,THIS_MODULE, "clr_msg", DEFAULT_CLRMSG);
	ps->clr_status=db_get_dw(NULL,THIS_MODULE, "clr_status", DEFAULT_CLRSTATUS);
	ps->clr_shadow=db_get_dw(NULL,THIS_MODULE, "clr_shadow", DEFAULT_CLRSHADOW);
	ps->bkclr=db_get_dw(NULL,THIS_MODULE, "bkclr", DEFAULT_BKCLR);

	ps->showMsgWindow=db_get_b(NULL,THIS_MODULE, "showMessageWindow", DEFAULT_SHOWMSGWIN);
	ps->showWhen=db_get_dw(NULL,THIS_MODULE,"showWhen", DEFAULT_SHOWWHEN);
	
	DBVARIANT dbv;
	if (!db_get_ts( NULL, THIS_MODULE, "message_format", &dbv )) {
		_tcscpy(ps->msgformat, dbv.ptszVal);
		db_free(&dbv);
	}
	else _tcscpy(ps->msgformat, DEFAULT_MESSAGEFORMAT);

	ps->announce=db_get_dw(NULL,THIS_MODULE,"announce", DEFAULT_ANNOUNCE);

	ps->lf.lfHeight=db_get_dw(NULL,THIS_MODULE, "fntHeight", DEFAULT_FNT_HEIGHT);
	ps->lf.lfWidth=db_get_dw(NULL,THIS_MODULE, "fntWidth", DEFAULT_FNT_WIDTH);
	ps->lf.lfEscapement=db_get_dw(NULL,THIS_MODULE, "fntEscapement", DEFAULT_FNT_ESCAPEMENT);
	ps->lf.lfOrientation=db_get_dw(NULL,THIS_MODULE, "fntOrientation", DEFAULT_FNT_ORIENTATION);
	ps->lf.lfWeight=db_get_dw(NULL,THIS_MODULE, "fntWeight", DEFAULT_FNT_WEIGHT);
	ps->lf.lfItalic=db_get_b(NULL,THIS_MODULE, "fntItalic", DEFAULT_FNT_ITALIC);
	ps->lf.lfUnderline=db_get_b(NULL,THIS_MODULE, "fntUnderline", DEFAULT_FNT_UNDERLINE);
	ps->lf.lfStrikeOut=db_get_b(NULL,THIS_MODULE, "fntStrikeout", DEFAULT_FNT_STRIKEOUT);
	ps->lf.lfCharSet=db_get_b(NULL,THIS_MODULE, "fntCharSet", DEFAULT_FNT_CHARSET);
	ps->lf.lfOutPrecision=db_get_b(NULL,THIS_MODULE, "fntOutPrecision", DEFAULT_FNT_OUTPRECISION);
	ps->lf.lfClipPrecision=db_get_b(NULL,THIS_MODULE, "fntClipPrecision", DEFAULT_FNT_CLIPRECISION);
	ps->lf.lfQuality=db_get_b(NULL,THIS_MODULE, "fntQuality", DEFAULT_FNT_QUALITY);
	ps->lf.lfPitchAndFamily=db_get_b(NULL,THIS_MODULE, "fntPitchAndFamily", DEFAULT_FNT_PITCHANDFAM);
	
	if(!db_get_ts(NULL,THIS_MODULE,"fntFaceName",&dbv)) {
		_tcscpy(ps->lf.lfFaceName, dbv.ptszVal);
		db_free(&dbv);
	}
	else
		_tcscpy(ps->lf.lfFaceName, DEFAULT_FNT_FACENAME);
}
Beispiel #3
0
MIR_CORE_DLL(HANDLE) TimeZone_CreateByContact(MCONTACT hContact, LPCSTR szModule, DWORD dwFlags)
{
	if (hContact == NULL && szModule == NULL)
		return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ;

	if (szModule == NULL) szModule = "UserInfo";

	DBVARIANT dbv;
	if (!db_get_ts(hContact, szModule, "TzName", &dbv)) {
		HANDLE res = TimeZone_CreateByName(dbv.ptszVal, dwFlags);
		db_free(&dbv);
		if (res) return res;
	}

	signed char timezone = (signed char)db_get_b(hContact, szModule, "Timezone", -1);
	if (timezone == -1) {
		char *szProto = GetContactProto(hContact);
		if (!db_get_ts(hContact, szProto, "TzName", &dbv)) {
			HANDLE res = TimeZone_CreateByName(dbv.ptszVal, dwFlags);
			db_free(&dbv);
			if (res) return res;
		}
		timezone = (signed char)db_get_b(hContact, szProto, "Timezone", -1);
	}

	if (timezone != -1) {
		MIM_TIMEZONE tzsearch;
		tzsearch.tzi.Bias = timezone * 30;
		if (myInfo.myTZ.tzi.Bias == tzsearch.tzi.Bias) {
			if (dwFlags & TZF_DIFONLY) return NULL;
			return &myInfo.myTZ;
		}

		int i = g_timezonesBias.getIndex(&tzsearch);
		while (i >= 0 && g_timezonesBias[i]->tzi.Bias == tzsearch.tzi.Bias) --i;

		int delta = LONG_MAX;
		for (int j = ++i; j < g_timezonesBias.getCount() && g_timezonesBias[j]->tzi.Bias == tzsearch.tzi.Bias; ++j) {
			int delta1 = abs(g_timezonesBias[j]->tzi.DaylightDate.wMonth - myInfo.myTZ.tzi.DaylightDate.wMonth);
			if (delta1 <= delta) {
				delta = delta1;
				i = j;
			}
		}

		if (i >= 0) {
			MIM_TIMEZONE *tz = g_timezonesBias[i];
			return ((dwFlags & TZF_DIFONLY) && IsSameTime(tz)) ? NULL : tz;
		}
	}
	return (dwFlags & (TZF_DIFONLY | TZF_KNOWNONLY)) ? NULL : &myInfo.myTZ;
}
Beispiel #4
0
// getting weather setting from database
// return 0 on success
int DBGetData(MCONTACT hContact, char *setting, DBVARIANT *dbv)
{
	if (db_get_ts(hContact, WEATHERCONDITION, setting, dbv)) {
		size_t len = mir_strlen(setting) + 1;
		char *set = (char*)alloca(len + 1);
		*set = '#';
		memcpy(set + 1, setting, len);

		if (db_get_ts(hContact, WEATHERCONDITION, set, dbv))
			return 1;
	}
	return 0;
}
Beispiel #5
0
static TCHAR* GetAwayMessage(int statusMode, char *szProto)
{
	if (szProto && !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode)))
		return NULL;

	if ( GetStatusModeByte(statusMode, "Ignore"))
		return NULL;

	DBVARIANT dbv;
	if ( GetStatusModeByte(statusMode, "UsePrev")) {
		if ( db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusMode, "Msg"), &dbv))
			dbv.ptszVal = mir_tstrdup(GetDefaultMessage(statusMode));
	}
	else {
		if ( db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusMode, "Default"), &dbv))
			dbv.ptszVal = mir_tstrdup(GetDefaultMessage(statusMode));

		for (int i=0; dbv.ptszVal[i]; i++) {
			if (dbv.ptszVal[i] != '%')
				continue;

			TCHAR substituteStr[128];
			if ( !_tcsnicmp(dbv.ptszVal + i, _T("%time%"), 6)) {
				MIRANDA_IDLE_INFO mii = { sizeof(mii) };
				CallService(MS_IDLE_GETIDLEINFO, 0, (LPARAM)&mii);

				if (mii.idleType == 1) {
					int mm;
					SYSTEMTIME t;
					GetLocalTime(&t);
					mm = t.wMinute + t.wHour * 60 - mii.idleTime;
					if (mm < 0) mm += 60 * 24;
					t.wMinute = mm % 60;
					t.wHour = mm / 60;
					GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &t, NULL, substituteStr, SIZEOF(substituteStr));
				}
				else GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, substituteStr, SIZEOF(substituteStr));
			}
			else if ( !_tcsnicmp(dbv.ptszVal + i, _T("%date%"), 6))
				GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, substituteStr, SIZEOF(substituteStr));
			else continue;

			if (lstrlen(substituteStr) > 6)
				dbv.ptszVal = (TCHAR*)mir_realloc(dbv.ptszVal, (lstrlen(dbv.ptszVal) + 1 + lstrlen(substituteStr) - 6) * sizeof(TCHAR));
			MoveMemory(dbv.ptszVal + i + lstrlen(substituteStr), dbv.ptszVal + i + 6, (lstrlen(dbv.ptszVal) - i - 5) * sizeof(TCHAR));
			CopyMemory(dbv.ptszVal+i, substituteStr, lstrlen(substituteStr) * sizeof(TCHAR));
		}
	}
	return dbv.ptszVal;
}
int GetStatusMessage(TCHAR *text, int text_size, ClcCacheEntry *pdnce, BOOL xstatus_has_priority)
{
	DBVARIANT dbv = { 0 };
	BOOL noAwayMsg = FALSE;
	WORD wStatus = pdnce___GetStatus(pdnce);
	text[0] = '\0';
	// Hide status text if Offline  /// no offline

	if (wStatus == ID_STATUS_OFFLINE || wStatus == 0) noAwayMsg = TRUE;
	// Get XStatusMsg
	if (!noAwayMsg  && xstatus_has_priority && pdnce->hContact && pdnce->m_cache_cszProto) {
		// Try to get XStatusMsg
		if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv)) {
			//mir_tstrncpy(text, dbv.pszVal, text_size);
			CopySkipUnprintableChars(text, dbv.ptszVal, text_size - 1);
			db_free(&dbv);

			if (text[0] != '\0')
				return -1;
		}
	}

	// Get StatusMsg
	if (pdnce->hContact && text[0] == '\0') {
		if (!db_get_ts(pdnce->hContact, "CList", "StatusMsg", &dbv)) {
			//mir_tstrncpy(text, dbv.pszVal, text_size);
			CopySkipUnprintableChars(text, dbv.ptszVal, text_size - 1);
			db_free(&dbv);

			if (text[0] != '\0')
				return 1;
		}
	}

	// Get XStatusMsg
	if (!noAwayMsg && !xstatus_has_priority && pdnce->hContact && pdnce->m_cache_cszProto && text[0] == '\0') {
		// Try to get XStatusMsg
		if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv)) {
			//mir_tstrncpy(text, dbv.pszVal, text_size);
			CopySkipUnprintableChars(text, dbv.ptszVal, text_size - 1);
			db_free(&dbv);

			if (text[0] != '\0')
				return -1;
		}
	}

	return 1;
}
Beispiel #7
0
void import_ping_address(int index, PINGADDRESS &pa) {
	DBVARIANT dbv;
	char buf[256];
	mir_snprintf(buf, "Address%d", index);
	if (!db_get_ts(0, "PingPlug", buf, &dbv)) {
		mir_tstrncpy(pa.pszName, dbv.ptszVal, _countof(pa.pszName));
		db_free(&dbv);
	}
	else
		mir_tstrncpy(pa.pszName, TranslateT("Unknown Address"), _countof(pa.pszName));

	mir_snprintf(buf, "Label%d", index);
	if (!db_get_ts(0, "PingPlug", buf, &dbv)) {
		mir_tstrncpy(pa.pszLabel, dbv.ptszVal, _countof(pa.pszLabel));
		db_free(&dbv);
	}
	else
		mir_tstrncpy(pa.pszLabel, TranslateT("Unknown"), _countof(pa.pszLabel));

	mir_snprintf(buf, "Port%d", index);
	pa.port = (int)db_get_dw(0, "PingPlug", buf, -1);

	mir_snprintf(buf, "Proto%d", index);
	if (!db_get_s(0, "PingPlug", buf, &dbv)) {
		mir_strncpy(pa.pszProto, dbv.pszVal, _countof(pa.pszProto));
		db_free(&dbv);
		mir_snprintf(buf, "Status%d", index);
		pa.set_status = db_get_w(0, "PingPlug", buf, ID_STATUS_ONLINE);
		mir_snprintf(buf, "Status2%d", index);
		pa.get_status = db_get_w(0, "PingPlug", buf, ID_STATUS_OFFLINE);
	}
	else
		pa.pszProto[0] = '\0';


	pa.responding = false;
	pa.round_trip_time = 0;
	pa.miss_count = 0;
	pa.index = index;
	pa.pszCommand[0] = '\0';
	pa.pszParams[0] = '\0';

	pa.item_id = 0;
	mir_snprintf(buf, "Enabled%d", index);
	if (db_get_b(0, "PingPlug", buf, 1) == 1)
		pa.status = PS_NOTRESPONDING;
	else
		pa.status = PS_DISABLED;
}
Beispiel #8
0
extern "C" int __declspec(dllexport) Load()
{
	mir_getLP(&pluginInfoEx);
	mir_getCLI();

	// Load plugin options from DB
	hForwardFrom = (MCONTACT)db_get_dw(NULL, "yaRelay", "ForwardFrom", 0);
	hForwardTo = (MCONTACT)db_get_dw(NULL, "yaRelay", "ForwardTo", 0);

	iForwardOnStatus = db_get_dw(NULL, "yaRelay", "ForwardOnStatus", STATUS_OFFLINE | STATUS_AWAY | STATUS_NA);

	DBVARIANT dbv;
	if (!db_get_ts(NULL, "yaRelay", "ForwardTemplate", &dbv)){
		_tcsncpy(tszForwardTemplate, dbv.ptszVal, SIZEOF(tszForwardTemplate));
		db_free(&dbv);
	}
	else _tcsncpy(tszForwardTemplate, _T("%u: %m"), MAXTEMPLATESIZE-1);

	iSplit          = db_get_dw(NULL, "yaRelay", "Split", 0);
	iSplitMaxSize   = db_get_dw(NULL, "yaRelay", "SplitMaxSize", 100);
	iSendParts      = db_get_dw(NULL, "yaRelay", "SendParts", 0);
	iMarkRead       = db_get_dw(NULL, "yaRelay", "MarkRead", 0);
	iSendAndHistory = db_get_dw(NULL, "yaRelay", "SendAndHistory", 1);

	// hook events
	HookEvent(ME_DB_EVENT_ADDED, MessageEventAdded);
	HookEvent(ME_OPT_INITIALISE, OptionsInit);
	HookEvent(ME_PROTO_ACK, ProtoAck);
	return 0;
}
Beispiel #9
0
void fnGetFontSetting(int i, LOGFONT* lf, COLORREF* colour)
{
	DBVARIANT dbv;
	char idstr[20];
	BYTE style;

	cli.pfnGetDefaultFontSetting(i, lf, colour);
	mir_snprintf(idstr, SIZEOF(idstr), "Font%dName", i);
	if (!db_get_ts(NULL, "CLC", idstr, &dbv)) {
		lstrcpy(lf->lfFaceName, dbv.ptszVal);
		mir_free(dbv.pszVal);
	}
	mir_snprintf(idstr, SIZEOF(idstr), "Font%dCol", i);
	*colour = db_get_dw(NULL, "CLC", idstr, *colour);
	mir_snprintf(idstr, SIZEOF(idstr), "Font%dSize", i);
	lf->lfHeight = (char) db_get_b(NULL, "CLC", idstr, lf->lfHeight);
	mir_snprintf(idstr, SIZEOF(idstr), "Font%dSty", i);
	style = (BYTE) db_get_b(NULL, "CLC", idstr, (lf->lfWeight == FW_NORMAL ? 0 : DBFONTF_BOLD) | (lf->lfItalic ? DBFONTF_ITALIC : 0) | (lf->lfUnderline ? DBFONTF_UNDERLINE : 0));
	lf->lfWidth = lf->lfEscapement = lf->lfOrientation = 0;
	lf->lfWeight = style & DBFONTF_BOLD ? FW_BOLD : FW_NORMAL;
	lf->lfItalic = (style & DBFONTF_ITALIC) != 0;
	lf->lfUnderline = (style & DBFONTF_UNDERLINE) != 0;
	lf->lfStrikeOut = 0;
	mir_snprintf(idstr, SIZEOF(idstr), "Font%dSet", i);
	lf->lfCharSet = db_get_b(NULL, "CLC", idstr, lf->lfCharSet);
	lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
	lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
	lf->lfQuality = DEFAULT_QUALITY;
	lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
}
Beispiel #10
0
INT_PTR GetProfileName(WPARAM wParam, LPARAM lParam)
{
    int profile = (int)wParam;
    if (profile < 0) // get default profile
        profile = db_get_w(NULL, MODULENAME, SETTING_DEFAULTPROFILE, 0);

    int count = db_get_w(NULL, MODULENAME, SETTING_PROFILECOUNT, 0);
    if (profile >= count && count > 0)
        return -1;

    TCHAR* buf = (TCHAR*)lParam;
    if (count == 0) {
        _tcsncpy(buf, TranslateT("default"), 128-1);
        return 0;
    }

    DBVARIANT dbv;
    char setting[80];
    mir_snprintf(setting, "%d_%s", profile, SETTING_PROFILENAME);
    if ( db_get_ts(NULL, MODULENAME, setting, &dbv))
        return -1;

    _tcsncpy(buf, dbv.ptszVal, 128-1);
    buf[127] = 0;
    db_free(&dbv);
    return 0;
}
Beispiel #11
0
void fnDeleteItemFromTree(HWND hwnd, MCONTACT hItem)
{
	ClcContact *contact;
	ClcGroup *group;
	struct ClcData *dat = (struct ClcData *) GetWindowLongPtr(hwnd, 0);

	dat->needsResort = 1;
	if (!cli.pfnFindItem(hwnd, dat, hItem, &contact, &group, NULL)) {
		DBVARIANT dbv;
		int i, nameOffset;
		if (!IsHContactContact(hItem))
			return;
		if (db_get_ts(hItem, "CList", "Group", &dbv))
			return;

		//decrease member counts of all parent groups too
		group = &dat->list;
		nameOffset = 0;
		for (i=0;; i++) {
			if (group->scanIndex == group->cl.count)
				break;
			if (group->cl.items[i]->type == CLCIT_GROUP) {
				size_t len = mir_tstrlen(group->cl.items[i]->szText);
				if (!_tcsncmp(group->cl.items[i]->szText, dbv.ptszVal + nameOffset, len) &&
					 (dbv.ptszVal[nameOffset + len] == '\\' || dbv.ptszVal[nameOffset + len] == '\0')) {
					group->totalMembers--;
					if (dbv.ptszVal[nameOffset + len] == '\0')
						break;
				}
			}
		}
		mir_free(dbv.ptszVal);
	}
	else cli.pfnRemoveItemFromGroup(hwnd, group, contact, 1);
}
Beispiel #12
0
int SaveUserSessionName(TCHAR *szUSessionName)
{
	int i=0;
	DBVARIANT  dbv={0};
	char szUserSessionNameBuf[256]={0};
	TCHAR *szUserSessionNameBuf_1=NULL;
	TCHAR *szUserSessionName=NULL;
	TCHAR *ptr=NULL;

	if (session_list[0]!=0)
	{
		szUserSessionName = mir_tstrdup(szUSessionName);
		mir_snprintf(szUserSessionNameBuf, SIZEOF(szUserSessionNameBuf), "%s_%u", "UserSessionDsc", 0);
		if (!db_get_ts(NULL, MODNAME, szUserSessionNameBuf, &dbv))
		{
			szUserSessionNameBuf_1 = mir_tstrdup(dbv.ptszVal);
			db_free(&dbv);
			ResaveSettings("UserSessionDsc",1,255,szUserSessionNameBuf_1);
		}

		db_set_ts(NULL, MODNAME, szUserSessionNameBuf, szUserSessionName);

		//free(szUserSessionNameBuf_1);
		mir_free(szUserSessionName);
		return 0;
	}

	return 1;
}
Beispiel #13
0
void logoff_contacts(BOOL bCleanup) {
	MCONTACT hContact;
	char *szProto;
	DBVARIANT dbv = { 0 };

	LOG(("logoff_contacts: Logging off contacts."));
	for (hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) {
		szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0);
		if (szProto != NULL && !strcmp(szProto, SKYPE_PROTONAME))
		{
			if (db_get_w(hContact, SKYPE_PROTONAME, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
				db_set_w(hContact, SKYPE_PROTONAME, "Status", ID_STATUS_OFFLINE);

			db_unset(hContact, SKYPE_PROTONAME, "CallId");
			if (db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) == 1)
			{
				if (db_get_ts(hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv)) continue;
				RemChat(dbv.ptszVal);
				db_free(&dbv);
			}
			if (db_get_s(hContact, SKYPE_PROTONAME, "Typing_Stream", &dbv) == 0)
			{
				if (bCleanup) SkypeSend("ALTER APPLICATION libpurple_typing DISCONNECT %s", dbv.pszVal);
				db_free(&dbv);
				db_unset(hContact, SKYPE_PROTONAME, "Typing_Stream");
			}

		}
	}
	if (bCleanup && (protocol >= 5 || bIsImoproxy)) SkypeSend("DELETE APPLICATION libpurple_typing");
}
Beispiel #14
0
INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
{
	DBVARIANT dbv;
	
	switch(msg) {
	case WM_INITDIALOG:
		mir_subclassWindow( GetDlgItem(hdlg, IDC_INFOTEXT), EditProc);
		{
			TCHAR *szout;
			if ( !db_get_ts(NULL, S_MOD, "UserStamp", &dbv)) {
				szout = ParseString(dbv.ptszVal, (HANDLE)lparam, 0);
				db_free(&dbv);
			}
			else szout = ParseString(DEFAULT_USERSTAMP, (HANDLE)lparam, 0);

			SetDlgItemText(hdlg, IDC_INFOTEXT, szout);
			if ( !lstrcmp(szout, TranslateT("<unknown>")))
				EnableWindow( GetDlgItem(hdlg, IDC_INFOTEXT), FALSE);
		}
		break;

	case WM_COMMAND:
		if (HIWORD(wparam) == EN_SETFOCUS)
			SetFocus( GetParent(hdlg));
		break;
	}

	return 0;
}
Beispiel #15
0
void LoadHistoryList(MCONTACT hContact, HWND hwnd, int nList)
{
	SendDlgItemMessage(hwnd, nList, LB_RESETCONTENT, 0, 0);
	int historyMax = db_get_w(NULL, S_MOD, "HistoryMax", 10);
	if (historyMax < 0)
		historyMax = 0;
	else if (historyMax > 99)
		historyMax = 99;
	if (historyMax == 0)
		return;

	int historyFirst = db_get_w(hContact, S_MOD, "HistoryFirst", 0);
	if (historyFirst >= historyMax)
		historyFirst = 0;

	int historyLast = db_get_w(hContact, S_MOD, "HistoryLast", 0);
	if (historyLast >= historyMax)
		historyLast = historyMax - 1;

	for (int i = historyLast; i != historyFirst;) {
		i = (i - 1 + historyMax) % historyMax;

		DBVARIANT dbv;
		if (!db_get_ts(hContact, S_MOD, BuildSetting(i), &dbv)) {
			SendDlgItemMessage(hwnd, nList, LB_ADDSTRING, 0, (LPARAM)dbv.ptszVal);
			db_free(&dbv);
		}
		else SendDlgItemMessage(hwnd, nList, LB_ADDSTRING, 0, (LPARAM)_T(""));
	}
}
/*
*	Get the text for First Line
*/
void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact)
{
	if (GetCurrentThreadId() != g_dwMainThreadID)
		return;

	ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(contact->hContact);
	TCHAR *name = pcli->pfnGetContactDisplayName(contact->hContact, 0);
	if (dat->first_line_append_nick && (!dat->force_in_dialog)) {
		DBVARIANT dbv = { 0 };
		if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "Nick", &dbv)) {
			TCHAR nick[_countof(contact->szText)];
			mir_tstrncpy(nick, dbv.ptszVal, _countof(contact->szText));
			db_free(&dbv);

			// They are the same -> use the name to keep the case
			if (mir_tstrcmpi(name, nick) == 0)
				mir_tstrncpy(contact->szText, name, _countof(contact->szText));
			else // Append then
				mir_sntprintf(contact->szText, _T("%s - %s"), name, nick);
		}
		else mir_tstrncpy(contact->szText, name, _countof(contact->szText));
	}
	else mir_tstrncpy(contact->szText, name, _countof(contact->szText));

	if (!dat->force_in_dialog) {
		SHORTDATA data = { 0 };
		Sync(CLUI_SyncGetShortData, (WPARAM)pcli->hwndContactTree, (LPARAM)&data);
		contact->ssText.ReplaceSmileys(&data, pdnce, contact->szText, dat->first_line_draw_smileys);
	}
}
Beispiel #17
0
static int ProcessChatEvent(WPARAM, LPARAM lParam)
{
	GCEVENT *gce = (GCEVENT*)lParam;
	if (gce == NULL || gce->pDest == NULL)
		return 0;

	GCDEST *gcd = (GCDEST*)gce->pDest;
	if (gcd->iType != GC_EVENT_MESSAGE)
		return 0;

	MCONTACT hContact = pci->FindRoom(gcd->pszModule, gcd->ptszID);
	if (hContact != 0) {
		ptrT nick(db_get_tsa(hContact, gcd->pszModule, "MyNick"));
		if (nick == NULL || gce->ptszText == NULL)
			return 0;
		if (_tcsstr(gce->ptszText, nick)) {
			isIgnoreSound = db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0);
			DBVARIANT dbv;
			if (!isIgnoreSound && !db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
				TCHAR PlaySoundPath[MAX_PATH] = { 0 };
				PathToAbsoluteT(dbv.ptszVal, PlaySoundPath);
				isOwnSound = 0;
				SkinPlaySoundFile(PlaySoundPath);
				db_free(&dbv);
				isOwnSound = 1;
			}
		}
	}

	return 0;
}
Beispiel #18
0
static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info)
{
	DBVARIANT dbv;
	if (!db_get_ts(NULL, "SRFile", "ScanCmdLine", &dbv)) {
		if (dbv.ptszVal[0]) {
			STARTUPINFO si = { 0 };
			si.cb = sizeof(si);
			TCHAR *pszReplace = _tcsstr(dbv.ptszVal, _T("%f"));
			TCHAR szCmdLine[768];
			if (pszReplace) {
				if (info->szFile[mir_tstrlen(info->szFile) - 1] == '\\')
					info->szFile[mir_tstrlen(info->szFile) - 1] = '\0';
				*pszReplace = 0;
				mir_sntprintf(szCmdLine, _T("%s\"%s\"%s"), dbv.ptszVal, info->szFile, pszReplace + 2);
			} else
				_tcsncpy_s(szCmdLine, dbv.ptszVal, _TRUNCATE);

			PROCESS_INFORMATION pi;
			if (CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
				if (WaitForSingleObject(pi.hProcess, 3600 * 1000) == WAIT_OBJECT_0)
					PostMessage(info->hwndReply, M_VIRUSSCANDONE, info->returnCode, 0);
				CloseHandle(pi.hProcess);
				CloseHandle(pi.hThread);
			}
		}
		db_free(&dbv);
	}
	mir_free(info->szFile);
	mir_free(info);
}
Beispiel #19
0
TCHAR* MyDBGetContactSettingTString(MCONTACT hContact, char* module, char* setting, TCHAR* out, size_t len, TCHAR *def)
{
	DBVARIANT dbv;

	out[0] = _T('\0');

	if (!db_get_ts(hContact, module, setting, &dbv)) {
		if (dbv.type == DBVT_ASCIIZ)
			MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, out, (int)len);
		else if (dbv.type == DBVT_UTF8)
			MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, out, (int)len);
		else if (dbv.type == DBVT_WCHAR)
			mir_tstrncpy(out, dbv.pwszVal, (int)len);
		else if (def != NULL)
			mir_tstrncpy(out, def, (int)len);

		db_free(&dbv);
	}
	else {
		if (def != NULL)
			mir_tstrncpy(out, def, (int)len);
	}

	return out;
}
Beispiel #20
0
void CConfig::LoadFontSettings(int iFont)
{
	if(iFont > FONT_SETTINGS -1 || iFont < 0)
		return;

	char szSetting[128];
	
	// Fixed Values
	m_logfont[iFont].lfOutPrecision = OUT_DEFAULT_PRECIS;
	m_logfont[iFont].lfClipPrecision = CLIP_DEFAULT_PRECIS;
	m_logfont[iFont].lfQuality = DEFAULT_QUALITY;
	m_logfont[iFont].lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
	// Height
	mir_snprintf(szSetting,SIZEOF(szSetting),"Font%dHeight",iFont);
	m_logfont[iFont].lfHeight = (char) db_get_b(NULL, "MirandaG15", szSetting, -MulDiv(6, 96, 72));
	// Style
	mir_snprintf(szSetting,SIZEOF(szSetting),"Font%dStyle",iFont);
	int style = db_get_b(NULL, "MirandaG15", szSetting, 0);
	m_logfont[iFont].lfWeight = style & FONTF_BOLD ? FW_BOLD : FW_NORMAL;
    m_logfont[iFont].lfItalic = style & FONTF_ITALIC ? 1 : 0;
	// Charset
	mir_snprintf(szSetting,SIZEOF(szSetting),"Font%dCharset",iFont);
	m_logfont[iFont].lfCharSet = db_get_b(NULL, "MirandaG15", szSetting, DEFAULT_CHARSET);
	// Name
	mir_snprintf(szSetting,SIZEOF(szSetting),"Font%dName",iFont);
	DBVARIANT dbv;
	if (db_get_ts(NULL, "MirandaG15", szSetting, &dbv))
        lstrcpy(m_logfont[iFont].lfFaceName,_T("Small Fonts"));
    else {
		lstrcpy(m_logfont[iFont].lfFaceName, dbv.ptszVal);
       db_free(&dbv);
    }

	UpdateFontSettings(iFont);
}
Beispiel #21
0
int LoadOptions(void)
{
	options.backup_types = (BackupType)db_get_b(0, "AutoBackups", "BackupType", (BYTE)(BT_PERIODIC));
	options.period = (unsigned int)db_get_w(0, "AutoBackups", "Period", 1);
	options.period_type = (PeriodType)db_get_b(0, "AutoBackups", "PeriodType", (BYTE)PT_DAYS);

	if (!ServiceExists(MS_FOLDERS_GET_PATH)) {
		DBVARIANT dbv;

		if (!db_get_ts(0, "AutoBackups", "Folder", &dbv)) {
			TCHAR *tmp = Utils_ReplaceVarsT(dbv.ptszVal);

			if (mir_tstrlen(tmp) >= 2 && tmp[1] == ':')
				_tcsncpy_s(options.folder, dbv.ptszVal, _TRUNCATE);
			else
				mir_sntprintf(options.folder, _countof(options.folder), _T("%s\\%s"), profilePath, dbv.ptszVal);

			db_free(&dbv);
			mir_free(tmp);
		}
		else
			mir_sntprintf(options.folder, _countof(options.folder), _T("%s%s"), DIR, SUB_DIR);
	}
	options.num_backups = db_get_w(0, "AutoBackups", "NumBackups", 3);

	options.disable_progress = (BOOL)db_get_b(0, "AutoBackups", "NoProgress", 0);
	options.disable_popups = (BOOL)db_get_b(0, "AutoBackups", "NoPopups", 0);
	options.use_zip = (BOOL)db_get_b(0, "AutoBackups", "UseZip", 0);

	SetBackupTimer();
	return 0;
}
Beispiel #22
0
int BuildContactMenu(WPARAM wparam,LPARAM)
{
	int id = -1, isetting;
	MCONTACT hContact = (MCONTACT)wparam;
	char *szProto = GetContactProto(hContact);

	CLISTMENUITEM cmi = { sizeof(cmi) };
	if (!IsWatchedProtocol(szProto) || !db_get_b(NULL,S_MOD,"MenuItem",1))
		cmi.flags = CMIM_FLAGS | CMIF_HIDDEN | CMIF_TCHAR;
	else {
		cmi.flags = CMIM_NAME | CMIM_FLAGS | CMIM_ICON | CMIF_TCHAR;
		cmi.hIcon = NULL;

		DBVARIANT dbv;
		if ( !db_get_ts(NULL, S_MOD, "MenuStamp", &dbv)) {
			cmi.ptszName = ParseString(dbv.ptszVal, (MCONTACT)wparam, 0);
			db_free(&dbv);
		}
		else cmi.ptszName = ParseString(DEFAULT_MENUSTAMP, (MCONTACT)wparam, 0);
		
		if ( !_tcscmp(cmi.ptszName, TranslateT("<unknown>"))) {	
			if ( IsWatchedProtocol(szProto))
				cmi.flags |= CMIF_GRAYED;
			else
				cmi.flags |= CMIF_HIDDEN;	
		}
		else if ( db_get_b(NULL, S_MOD, "ShowIcon",1)) {
			isetting = db_get_w(hContact, S_MOD, "StatusTriger", -1);
			cmi.hIcon = LoadSkinnedProtoIcon(szProto, isetting|0x8000);
		}
	}

	Menu_ModifyItem(hmenuitem, &cmi);
	return 0;
}
Beispiel #23
0
void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc)
{
	CMString tname(A2T_SM(acc->szModuleName));

	for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
		char* proto = GetContactProto(hContact);
		if (proto == NULL)
			continue;

		DBVARIANT dbv;
		if (!db_get_ts(hContact, proto, "Transport", &dbv)) {
			bool found = (tname.CompareNoCase(dbv.ptszVal) == 0);
			db_free(&dbv);
			if (found)
				return;
		}
	}

	for (int i = 0; i < m_SmileyCategories.getCount(); i++) {
		if (tname.CompareNoCase(m_SmileyCategories[i].GetName()) == 0) {
			m_SmileyCategories.remove(i);
			break;
		}
	}
}
Beispiel #24
0
static int MsgEventAdded(WPARAM wParam,LPARAM lParam)
{
	HANDLE hDbEvent = (HANDLE)lParam;

	if (currentWatcherType & SDWTF_MESSAGE) {
		DBEVENTINFO dbe = { sizeof(dbe) };
		dbe.cbBlob = db_event_getBlobSize(hDbEvent);
		dbe.pBlob = (BYTE*)mir_alloc(dbe.cbBlob+2); /* ensure term zero */
		if (dbe.pBlob == NULL)
			return 0;
		if (!db_event_get(hDbEvent, &dbe))
			if (dbe.eventType == EVENTTYPE_MESSAGE && !(dbe.flags & DBEF_SENT)) {
				DBVARIANT dbv;
				if (!db_get_ts(NULL,"AutoShutdown","Message",&dbv)) {
					TrimString(dbv.ptszVal);
					TCHAR *pszMsg = GetMessageText(&dbe.pBlob,&dbe.cbBlob);
					if (pszMsg != NULL && _tcsstr(pszMsg,dbv.ptszVal) != NULL)
						ShutdownAndStopWatcher(); /* msg with specified text recvd */
					mir_free(dbv.ptszVal); /* does NULL check */
				}
			}
		mir_free(dbe.pBlob);
	}
	return 0;
}
Beispiel #25
0
void CleanSettings(int buttonnum,int from)
{
	char szMEntry[256]={'\0'};
	DBVARIANT dbv = {0};
	if(from==-1){
		mir_snprintf(szMEntry,SIZEOF(szMEntry),"ButtonName_%u",buttonnum);
		db_unset(NULL, PLGNAME,szMEntry);
		mir_snprintf(szMEntry,SIZEOF(szMEntry),"ButtonValue_%u",buttonnum);
		db_unset(NULL, PLGNAME,szMEntry);
		mir_snprintf(szMEntry,SIZEOF(szMEntry),"RCEntryIsServiceName_%u",buttonnum);
		db_unset(NULL, PLGNAME,szMEntry);
	}

	mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryName_%u_%u",buttonnum,from);
	while(!db_get_ts(NULL, PLGNAME,szMEntry,&dbv)) {
		db_unset(NULL, PLGNAME,szMEntry);
		mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryValue_%u_%u",buttonnum,from);
		db_unset(NULL, PLGNAME,szMEntry);
		mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryRel_%u_%u",buttonnum,from);
		db_unset(NULL, PLGNAME,szMEntry);
		mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryToQMenu_%u_%u",buttonnum,from);
		db_unset(NULL, PLGNAME,szMEntry);
		mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryIsServiceName_%u_%u",buttonnum,from);
		db_unset(NULL, PLGNAME,szMEntry);

		mir_snprintf(szMEntry,SIZEOF(szMEntry),"EntryName_%u_%u",buttonnum,++from);
	}
	db_free(&dbv);
}
Beispiel #26
0
TCHAR* getMenuEntry(int buttonnum, int entrynum, BYTE mode) 
{	  
	TCHAR* buffer = NULL;
	char szMEntry[256];
	DBVARIANT dbv;

	switch (mode) {
	case 0:
		mir_snprintf(szMEntry, SIZEOF(szMEntry), "EntryName_%u_%u", buttonnum, entrynum);
		break;
	case 1:
		mir_snprintf(szMEntry, SIZEOF(szMEntry), "EntryValue_%u_%u", buttonnum, entrynum);
		break;
	case 2:
		mir_snprintf(szMEntry, SIZEOF(szMEntry), "ButtonValue_%u", buttonnum);
		break;
	case 3:
		mir_snprintf(szMEntry, SIZEOF(szMEntry), "ButtonName_%u", buttonnum);
		break;
	default:
		szMEntry[0] = 0;
		break;
	}

	if (!db_get_ts(NULL, PLGNAME, szMEntry, &dbv)) {
		if (_tcslen(dbv.ptszVal))
			buffer = mir_tstrdup(dbv.ptszVal);
		db_free(&dbv);
	}

	return buffer; 
}
Beispiel #27
0
void HistoryWrite(MCONTACT hContact)
{
	int historyMax = db_get_w(NULL, S_MOD, "HistoryMax", 10);
	if (historyMax < 0)
		historyMax = 0;
	else if (historyMax > 99)
		historyMax = 99;
	if (historyMax == 0)
		return;

	int historyFirst = db_get_w(hContact, S_MOD, "HistoryFirst", 0);
	if (historyFirst >= historyMax)
		historyFirst = 0;

	int historyLast = db_get_w(hContact, S_MOD, "HistoryLast", 0);
	if (historyLast >= historyMax)
		historyLast = historyMax - 1;

	TCHAR *ptszString;
	DBVARIANT dbv;
	if (!db_get_ts(NULL, S_MOD, "HistoryStamp", &dbv)) {
		ptszString = ParseString(dbv.ptszVal, hContact);
		db_free(&dbv);
	}
	else ptszString = ParseString(DEFAULT_HISTORYSTAMP, hContact);
	db_set_ts(hContact, S_MOD, BuildSetting(historyLast), ptszString);

	historyLast = (historyLast + 1) % historyMax;
	db_set_w(hContact, S_MOD, "HistoryLast", historyLast);
	if (historyLast == historyFirst)
		db_set_w(hContact, S_MOD, "HistoryFirst", (historyFirst + 1) % historyMax);
}
Beispiel #28
0
/*
Prepares the log file:
- calculates the absolute path (and store it in the db)
- creates the directory

*/
int InitFileOutput(void)
{
	TCHAR szfpath[MAX_PATH], szmpath[MAX_PATH];
	GetModuleFileName(NULL, szmpath, MAX_PATH);

	DBVARIANT dbv;
	if(!db_get_ts(NULL, S_MOD, "FileName", &dbv))
	{
		_tcsncpy(szfpath, dbv.ptszVal, MAX_PATH);
		db_free(&dbv);
	}
	else _tcsncpy(szfpath, DEFAULT_FILENAME, MAX_PATH);

	if (szfpath[0] == '\\')
		_tcsncpy(szfpath, szfpath+1, MAX_PATH);

	TCHAR *str = _tcsrchr(szmpath, '\\');
	if (str != NULL)
		*++str=0;

	_tcsncat(szmpath, szfpath, MAX_PATH);
	_tcsncpy(szfpath, szmpath, MAX_PATH);

	str = _tcsrchr(szmpath, '\\');
	if (str != NULL)
		*++str=0;

	db_set_ts(NULL, S_MOD, "PathToFile", szfpath);
	return 0;
}
Beispiel #29
0
BOOL ResaveSettings(char* szName,int iFirst,int iLimit,TCHAR* szBuffer)
{
	BYTE marked,marked_t;
	char szNameBuf[256]={0};

	for (int i = iFirst; i < iLimit; i++) {
		if (szBuffer == NULL)
			break;

		mir_snprintf(szNameBuf, SIZEOF(szNameBuf), "%s_%u", szName, i);

		DBVARIANT dbv_temp;
		int res = db_get_ts(NULL, MODNAME, szNameBuf, &dbv_temp);
		db_set_ts(NULL, MODNAME, szNameBuf, szBuffer);
		mir_free(szBuffer);

		marked = IsMarkedUserDefSession(i);
		MarkUserDefSession(i,(BYTE)((i == iFirst)?IsMarkedUserDefSession(iFirst-1):marked_t));
		marked_t = marked;

		if (res) // read failed
			return 0;
			
		szBuffer = mir_tstrdup(dbv_temp.ptszVal);
		db_free(&dbv_temp);
	}

	mir_free(szBuffer);
	return 1;
}
Beispiel #30
0
void CreateAuthString(char *auth, MCONTACT hContact, HWND hwndDlg)
{
	DBVARIANT dbv;
	char *user = NULL, *pass = NULL;
	TCHAR *tlogin = NULL, *tpass = NULL, buf[MAX_PATH] = {0};
	if (hContact && db_get_b(hContact, MODULE, "UseAuth", 0)) {
		if (!db_get_ts(hContact, MODULE, "Login", &dbv)) {
			tlogin = mir_tstrdup(dbv.ptszVal);
			db_free(&dbv);
		}
		tpass = db_get_tsa(hContact, MODULE, "Password");
	}
	else if (hwndDlg && IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
		GetDlgItemText(hwndDlg, IDC_LOGIN, buf, SIZEOF(buf));
		tlogin = mir_tstrdup(buf);
		GetDlgItemText(hwndDlg, IDC_PASSWORD, buf, SIZEOF(buf));
		tpass = mir_tstrdup(buf);
	}
	user = mir_t2a(tlogin);
	pass = mir_t2a(tpass);

	char str[MAX_PATH];
	int len = mir_snprintf(str, SIZEOF(str), "%s:%s", user, pass);
	mir_free(user);
	mir_free(pass);
	mir_free(tlogin);
	mir_free(tpass);

	mir_snprintf(auth, 250, "Basic %s", ptrA(mir_base64_encode((PBYTE)str, len)));
}