Example #1
0
static  BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
	DWORD dwPID;
	const TCHAR *lpszClassName;


	GetWindowThreadProcessId(hWnd,&dwPID);
	if (lParam != 0 && dwPID != (DWORD)lParam) return TRUE;
	lpszClassName = getClassName(hWnd);
	if(_tcscmp(lpszClassName, _T("tSkMainForm.UnicodeClass")) == 0 ||
		_tcscmp(lpszClassName, _T("TLoginForm.UnicodeClass")) == 0)
	{
		HWND loginControl = GetWindow(hWnd, GW_CHILD);

		LOG(("setUserNamePasswordThread: Skype window found!"));

		// Sleep for some time, while Skype is loading
		// It loads slowly :(
		//Sleep(5000);
		LOG (("TLoginControl = %S", getClassName(loginControl)));

		// Check for login control
		if(_tcscmp(getClassName(loginControl), _T("TLoginControl")) == 0)
		{
			// Find user name window
			HWND userName = findWindow(loginControl, _T("TNavigableTntComboBox.UnicodeClass"));
			HWND password = findWindow(loginControl, _T("TNavigableTntEdit.UnicodeClass"));

			LOG (("userName=%08X; password=%08X", userName, password));
			if (userName && password)
			{
				// Set user name and password
				DBVARIANT dbv;

				if(!DBGetContactSettingWString(NULL,SKYPE_PROTONAME,"LoginUserName",&dbv)) 
				{
					SendMessageW(userName, WM_SETTEXT, 0, (LPARAM)dbv.pwszVal);
					DBFreeVariant(&dbv);    
				}

				if(!DBGetContactSettingWString(NULL,SKYPE_PROTONAME,"LoginPassword",&dbv)) 
				{
					SendMessageW(password, WM_SETTEXT, 0, (LPARAM)dbv.pwszVal);
					DBFreeVariant(&dbv);
					SendMessageW(password, WM_CHAR, 13, 0);
				}


				SendMessageW(hWnd,
							 WM_COMMAND,
							 0x4a8,  // sign-in button; WARNING: This ID can change during newer Skype versions
							 (LPARAM)findWindow(loginControl, _T("TTntButton.UnicodeClass")));
			}
			return FALSE;
		}

	}
	return TRUE;
}
HANDLE CDatabase::FindContact(const wchar_t* uri) const
{
    MTLASSERT(uri);

    HANDLE hContact = reinterpret_cast<HANDLE>(CallService(MS_DB_CONTACT_FINDFIRST, 0, 0));
    while(hContact)
    {
        const char* protocol = reinterpret_cast<const char*>(CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0));
        if(protocol && !lstrcmpA(protocol, g_env.ProtocolName()))
        {
            if(DBGetContactSettingByte(hContact, g_env.ProtocolName(), "ChatRoom", 0) == 0)  // Chat API support
            {
                DBVARIANT dbv;
                if(S_OK == DBGetContactSettingWString(hContact, g_env.ProtocolName(), "uri", &dbv))
                {
                    MTLASSERT(DBVT_WCHAR == dbv.type);

                    bool found = 0 == lstrcmpiW(dbv.pwszVal, uri);

                    DBFreeVariant(&dbv);

                    if(found)
                    {
                        return hContact;
                    }
                }
            }
        }

        hContact = reinterpret_cast<HANDLE>(CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0));
    }

    return 0;
}
Example #3
0
int CIcqProto::getSettingStringW(HANDLE hContact, const char *szSetting, DBVARIANT *dbv)
{
  int res = DBGetContactSettingWString(hContact, m_szModuleName, szSetting, dbv);

  if (res)
    ICQFreeVariant(dbv);

	return res;
}
wchar_t*  __cdecl ModernGetStringW( HANDLE hContact, const char *szModule, const char *szSetting )
{
	wchar_t *str=NULL;
	DBVARIANT dbv={0};
	DBGetContactSettingWString(hContact,szModule,szSetting,&dbv);
	if(dbv.type==DBVT_WCHAR)
		str=mir_wstrdup(dbv.pwszVal);
	DBFreeVariant(&dbv);
	return str;
}
void MirandaSkinnedDialog::getSettting(const char *name, const WCHAR *defVal, std::wstring &ret, bool global)
{
	char setting[SETTING_NAME_SIZE];
	getSettingName(setting, name, global);

	DBVARIANT dbv = {0};
	if (DBGetContactSettingWString(NULL, getModule(), setting, &dbv))
	{
		ret = defVal;
		return;
	}

	ret = dbv.pwszVal;
	DBFreeVariant(&dbv);
}
Example #6
0
static int GetDatabaseString( CONTACTINFO *ci, const char* setting, DBVARIANT* dbv )
{
    if (strcmp(ci->szProto, "CList") && CallProtoService(ci->szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC)
    {
        DBCONTACTGETSETTING cgs = { ci->szProto, setting, dbv };
        dbv->type = (ci->dwFlag & CNF_UNICODE) ? DBVT_WCHAR : DBVT_ASCIIZ;

        int res = CallProtoService(ci->szProto, PS_GETINFOSETTING, (WPARAM)ci->hContact, (LPARAM)&cgs);
        if (res != CALLSERVICE_NOTFOUND) return res;
    }

	if ( ci->dwFlag & CNF_UNICODE )
		return DBGetContactSettingWString(ci->hContact,ci->szProto,setting,dbv);

	return DBGetContactSettingString(ci->hContact,ci->szProto,setting,dbv);
}
bstr_t CDatabase::GetMySettingWString(const char* module, const char* param) const
{
    MTLASSERT(param && lstrlenA(param) > 0);

    bstr_t res(L"");

    DBVARIANT dbv;
    if(S_OK == DBGetContactSettingWString(0, module, param, &dbv))
    {
        MTLASSERT(DBVT_WCHAR == dbv.type);

        res = bstr_t(dbv.pwszVal);

        DBFreeVariant(&dbv);
    }

    return res;
}
int GetFontSettingFromDBW(char *settings_group, char *prefix, LOGFONTW * lf, COLORREF * colour, DWORD flags)
{
    DBVARIANT dbv;
    char idstr[256];
    BYTE style;
	int retval = 0;

    GetDefaultFontSettingW(lf, colour);
   
	if(flags & FIDF_APPENDNAME) sprintf(idstr, "%sName", prefix);
    else sprintf(idstr, "%s", prefix);

	if (!DBGetContactSettingWString(NULL, settings_group, idstr, &dbv)) {
		wcscpy(lf->lfFaceName, dbv.pwszVal);
		mir_free(dbv.pwszVal);
	} else if(!DBGetContactSetting(NULL, settings_group, idstr, &dbv)) {
		if(dbv.type == DBVT_ASCIIZ) {
			wchar_t buff[1024];
			MultiByteToWideChar(code_page, 0, dbv.pszVal, -1, buff, 1024);
			wcscpy(lf->lfFaceName, buff);
		} else
			retval = 1;
		DBFreeVariant(&dbv);
	} else 
		retval = 1;

	if(colour) {
	    sprintf(idstr, "%sCol", prefix);
		*colour = DBGetContactSettingDword(NULL, settings_group, idstr, *colour);
	}

    sprintf(idstr, "%sSize", prefix);
    lf->lfHeight = (char)DBGetContactSettingByte(NULL, settings_group, idstr, lf->lfHeight);
	
    
	//wsprintf(idstr, "%sFlags", prefix);
	//if(DBGetContactSettingDword(NULL, settings_group, idstr, 0) & FIDF_SAVEACTUALHEIGHT) {
	//	HDC hdc = GetDC(0);
	//	lf->lfHeight = -lf->lfHeight;
	//	ReleaseDC(0, hdc);
	//}

    sprintf(idstr, "%sSty", prefix);
    style = (BYTE) DBGetContactSettingByte(NULL, settings_group, idstr, 
		(lf->lfWeight == FW_NORMAL ? 0 : DBFONTF_BOLD) | (lf->lfItalic ? DBFONTF_ITALIC : 0) | (lf->lfUnderline ? DBFONTF_UNDERLINE : 0) | lf->lfStrikeOut ? DBFONTF_STRIKEOUT : 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 = (style & DBFONTF_STRIKEOUT) != 0;
    
	sprintf(idstr, "%sSet", prefix);
    lf->lfCharSet = DBGetContactSettingByte(NULL, settings_group, idstr, lf->lfCharSet);
    
	lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
    lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
    lf->lfQuality = DEFAULT_QUALITY;
    lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;

	if(lf->lfHeight > 0) {
		HDC hdc = GetDC(0);
		if(flags & FIDF_SAVEPOINTSIZE) {
			lf->lfHeight = -MulDiv(lf->lfHeight,GetDeviceCaps(hdc, LOGPIXELSY), 72);
		} else { // assume SAVEACTUALHEIGHT
			TEXTMETRIC tm;
			HFONT hFont = CreateFontIndirectW(lf);
			HFONT hOldFont = (HFONT)SelectObject(hdc, hFont);

			GetTextMetrics(hdc, &tm);

			lf->lfHeight = -(lf->lfHeight - tm.tmInternalLeading);

			SelectObject(hdc, hOldFont);
			DeleteObject(hFont);
		}
		//lf->lfHeight = -MulDiv(lf->lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
		ReleaseDC(0, hdc);
	}
	
	return retval;
}
Example #9
0
static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	AwayMsgDlgData *dat = (AwayMsgDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

	switch(message) 
	{
		case WM_INITDIALOG:
			TranslateDialogDefault(hwndDlg);
			dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData));
			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);

			dat->hContact = (HANDLE)lParam;
			dat->hAwayMsgEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_AWAYMSG);
			dat->hSeq = (HANDLE)CallContactService(dat->hContact, PSS_GETAWAYMSG, 0, 0);
			WindowList_Add(hWindowList, hwndDlg, dat->hContact);

			{	
				TCHAR  str[256], format[128];
				TCHAR* contactName = cli.pfnGetContactDisplayName(dat->hContact, 0);
				char*  szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0);
				WORD   dwStatus = DBGetContactSettingWord(dat->hContact, szProto, "Status", ID_STATUS_OFFLINE);
				TCHAR* status = cli.pfnGetStatusModeDescription(dwStatus, 0);
				
				GetWindowText(hwndDlg, format, SIZEOF(format));
				mir_sntprintf(str, SIZEOF(str), format, status, contactName);
				SetWindowText(hwndDlg, str);

				GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, SIZEOF(format));
				mir_sntprintf(str, SIZEOF(str), format, status);
				SetDlgItemText(hwndDlg, IDC_RETRIEVING, str);

				Window_SetProtoIcon_IcoLib(hwndDlg, szProto, dwStatus);
			}
			if (dat->hSeq == NULL)
			{
				ACKDATA ack = {0};
				ack.cbSize = sizeof(ack);
				ack.hContact = dat->hContact; 
				ack.type = ACKTYPE_AWAYMSG;
				ack.result = ACKRESULT_SUCCESS;
				SendMessage(hwndDlg, HM_AWAYMSG, 0, (LPARAM)&ack);
			}
			Utils_RestoreWindowPosition(hwndDlg, (HANDLE)lParam, "SRAway", "AwayMsgDlg");
			return TRUE;

		case HM_AWAYMSG:
		{	
			ACKDATA *ack = (ACKDATA*)lParam;
			if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) break;
			if (ack->result != ACKRESULT_SUCCESS) break;
			if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; }

#ifdef _UNICODE
			DBVARIANT dbv;
			bool unicode = !DBGetContactSetting(dat->hContact, "CList", "StatusMsg", &dbv) && 
				(dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR);
			DBFreeVariant(&dbv);
			if (unicode) 
			{
				DBGetContactSettingWString(dat->hContact, "CList", "StatusMsg", &dbv);
				SetDlgItemText(hwndDlg, IDC_MSG, dbv.pwszVal);
			}
			else 
#endif	
				SetDlgItemTextA(hwndDlg, IDC_MSG, (const char*)ack->lParam);

			ShowWindow(GetDlgItem(hwndDlg,IDC_RETRIEVING), SW_HIDE);
			ShowWindow(GetDlgItem(hwndDlg,IDC_MSG), SW_SHOW);
			SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close"));
			break;
		}

		case WM_COMMAND:
			switch(LOWORD(wParam)) 
			{
				case IDCANCEL:
				case IDOK:
					DestroyWindow(hwndDlg);
					break;
			}
			break;

		case WM_CLOSE:
			DestroyWindow(hwndDlg);
			break;

		case WM_DESTROY:
			if (dat->hAwayMsgEvent) UnhookEvent(dat->hAwayMsgEvent);
			Utils_SaveWindowPosition(hwndDlg,dat->hContact,"SRAway","AwayMsgDlg");
			WindowList_Remove(hWindowList,hwndDlg);
			Window_FreeIcon_IcoLib(hwndDlg);
			mir_free(dat);
			break;
	}
	return FALSE;
}