static void SetExtraIcons(HANDLE hContact) { if (hContact == NULL) return; char *proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); if (IsEmpty(proto)) return; for (unsigned int i = 0; i < MAX_REGS(infos); ++i) { Info &info = infos[i]; bool show = false; for (unsigned int j = 0; !show && j < MAX_REGS(info.db); j += 2) { if (info.db[j + 1] == NULL) break; DBVARIANT dbv = { 0 }; if (!DBGetContactSettingString(hContact, info.db[j] == NULL ? proto : info.db[j], info.db[j+1], &dbv)) { if (!IsEmpty(dbv.pszVal)) { info.SetIcon(hContact, &info, dbv.pszVal); show = true; } DBFreeVariant(&dbv); } } } }
int FacebookProto::RemoveFriend(WPARAM wParam,LPARAM lParam) { if (wParam == NULL) { // self contact // CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(FACEBOOK_URL_PROFILE)); return 0; } if (isOffline()) return 0; if (MessageBox( 0, TranslateT("Are you sure?"), TranslateT("Delete contact from server list"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2 ) != IDYES) return 0; HANDLE hContact = reinterpret_cast<HANDLE>(wParam); DBVARIANT dbv; if( !DBGetContactSettingString(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv) ) { if (!isOffline()) { std::string* id = new std::string(dbv.pszVal); ForkThread( &FacebookProto::DeleteContactFromServer, this, ( void* )id ); DBFreeVariant(&dbv); if ( !DBGetContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, 0) ) DBWriteContactSettingDword(hContact, m_szModuleName, FACEBOOK_KEY_DELETED, ::time(NULL)); } } return 0; }
// Avatars support void gg_getavatarfilename(GGPROTO *gg, HANDLE hContact, char *pszDest, int cbLen) { int tPathLen; char *path = (char *)_malloca(cbLen); char *avatartype = NULL; if (gg->hAvatarsFolder == NULL || FoldersGetCustomPath(gg->hAvatarsFolder, path, cbLen, "")) { char *tmpPath = Utils_ReplaceVars("%miranda_avatarcache%"); tPathLen = mir_snprintf(pszDest, cbLen, "%s\\%s", tmpPath, GG_PROTO); mir_free(tmpPath); } else { strcpy(pszDest, path); tPathLen = (int)strlen(pszDest); } if (_access(pszDest, 0)) CallService(MS_UTILS_CREATEDIRTREE, 0, (LPARAM)pszDest); switch (DBGetContactSettingByte(hContact, GG_PROTO, GG_KEY_AVATARTYPE, GG_KEYDEF_AVATARTYPE)) { case PA_FORMAT_JPEG: avatartype = "jpg"; break; case PA_FORMAT_GIF: avatartype = "gif"; break; case PA_FORMAT_PNG: avatartype = "png"; break; } if (hContact != NULL) { DBVARIANT dbv; if (!DBGetContactSettingString(hContact, GG_PROTO, GG_KEY_AVATARHASH, &dbv)) { mir_snprintf(pszDest + tPathLen, cbLen - tPathLen, "\\%s.%s", dbv.pszVal, avatartype); DBFreeVariant(&dbv); } } else mir_snprintf(pszDest + tPathLen, cbLen - tPathLen, "\\%s avatar.%s", GG_PROTO, avatartype); }
static INT_PTR Proto_RemoveFromContact(WPARAM wParam,LPARAM lParam) { int i; DBVARIANT dbv; char str[10]; i = Proto_IsProtoOnContact(wParam,lParam); if(!i) return 1; if(i==-1) DBDeleteContactSetting((HANDLE)wParam,"Protocol","p"); else { for(i--;;i++) { //we have to decrease i, as Proto_IsOnContact returns +1 more number than read from database _itoa(i+1,str,10); if(0!=DBGetContactSettingString((HANDLE)wParam,"_Filter",str,&dbv)) { _itoa(i,str,10); DBDeleteContactSetting((HANDLE)wParam,"_Filter",str); break; } _itoa(i,str,10); DBWriteContactSettingString((HANDLE)wParam,"_Filter",str,dbv.pszVal); mir_free(dbv.pszVal); } } return 0; }
static void addWindow(HANDLE hContact) { CLISTFrame Frame = {0}; HWND hWnd; DBVARIANT dbv; char winname[512]; DWORD frameID; DBGetContactSettingString(hContact, WEATHERPROTONAME, "Nick", &dbv); mir_snprintf(winname, sizeof(winname), "Weather: %s", dbv.pszVal); DBFreeVariant(&dbv); hWnd = CreateWindow("WeatherFrame", "", WS_CHILD | WS_VISIBLE, 0, 0, 10, 10, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL, hInst, hContact); Frame.name = winname; Frame.cbSize = sizeof(Frame); Frame.hWnd = hWnd; Frame.align = alBottom; Frame.Flags = F_VISIBLE|F_NOBORDER; Frame.height = 32; WindowList_Add(hMwinWindowList, hWnd, hContact); frameID = CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); DBWriteContactSettingDword(hContact, WEATHERPROTONAME, "mwin", frameID); DBWriteContactSettingByte(hContact, "CList", "Hidden", TRUE); }
int FacebookProto::AddFriend(WPARAM wParam,LPARAM lParam) { if (wParam == NULL) { // self contact // CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(FACEBOOK_URL_PROFILE)); return 0; } if (isOffline()) return 0; HANDLE hContact = reinterpret_cast<HANDLE>(wParam); DBVARIANT dbv; if( !DBGetContactSettingString(hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv) ) { if (!isOffline()) { std::string* id = new std::string(dbv.pszVal); ForkThread( &FacebookProto::AddContactToServer, this, ( void* )id ); DBFreeVariant(&dbv); } } return 0; }
void logoff_contacts(BOOL bCleanup) { HANDLE hContact; char *szProto; DBVARIANT dbv={0}; LOG(("logoff_contacts: Logging off contacts.")); for (hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);hContact != NULL;hContact=(HANDLE)CallService( MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) { szProto = (char*)CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0 ); if (szProto!=NULL && !strcmp(szProto, SKYPE_PROTONAME)) { if (DBGetContactSettingWord(hContact, SKYPE_PROTONAME, "Status", ID_STATUS_OFFLINE)!=ID_STATUS_OFFLINE) DBWriteContactSettingWord(hContact, SKYPE_PROTONAME, "Status", ID_STATUS_OFFLINE); DBDeleteContactSetting(hContact, SKYPE_PROTONAME, "CallId"); if (DBGetContactSettingByte(hContact, SKYPE_PROTONAME, "ChatRoom", 0)==1) { if (DBGetContactSettingTString(hContact, SKYPE_PROTONAME, "ChatRoomID", &dbv)) continue; RemChat (dbv.ptszVal); DBFreeVariant(&dbv); } if (DBGetContactSettingString(hContact, SKYPE_PROTONAME, "Typing_Stream", &dbv) == 0) { if (bCleanup) SkypeSend ("ALTER APPLICATION libpurple_typing DISCONNECT %s", dbv.pszVal); DBFreeVariant(&dbv); DBDeleteContactSetting(hContact, SKYPE_PROTONAME, "Typing_Stream"); } } } if (bCleanup && (protocol>=5 || bIsImoproxy)) SkypeSend ("DELETE APPLICATION libpurple_typing"); }
static char *GetNetlibUserSettingString(const char *szUserModule,const char *szSetting,int decode) { DBVARIANT dbv; if(DBGetContactSettingString(NULL,szUserModule,szSetting,&dbv) && DBGetContactSettingString(NULL,"Netlib",szSetting,&dbv)) { return NULL; } else { char *szRet; if(decode) CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM)dbv.pszVal); szRet=mir_strdup(dbv.pszVal); DBFreeVariant(&dbv); if(szRet==NULL) SetLastError(ERROR_OUTOFMEMORY); return szRet; } }
void TwitterProto::UpdateAvatar(HANDLE hContact,const std::string &url,bool force) { DBVARIANT dbv; if( !force && ( !DBGetContactSettingString(hContact,m_szModuleName,TWITTER_KEY_AV_URL,&dbv) && url == dbv.pszVal) ) { LOG("***** Avatar already up-to-date: %s",url.c_str()); } else { // TODO: more defaults (configurable?) if(url == "http://static.twitter.com/images/default_profile_normal.png") { PROTO_AVATAR_INFORMATION ai = {sizeof(ai),hContact}; db_string_set(hContact,m_szModuleName,TWITTER_KEY_AV_URL,url.c_str()); ProtoBroadcastAck(m_szModuleName,hContact,ACKTYPE_AVATAR, ACKRESULT_SUCCESS,&ai,0); } else { ForkThread(&TwitterProto::UpdateAvatarWorker, this, new update_avatar(hContact,url)); } } DBFreeVariant(&dbv); }
static int DefaultOnClick(WPARAM wParam, LPARAM lParam, LPARAM param) { Info *info = (Info *) param; if (info == NULL) return 0; HANDLE hContact = (HANDLE) wParam; if (hContact == NULL) return 0; char *proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); if (IsEmpty(proto)) return 0; bool found = false; for (unsigned int j = 0; !found && j < MAX_REGS(info->db); j += 2) { if (info->db[j + 1] == NULL) break; DBVARIANT dbv = { 0 }; if (!DBGetContactSettingString(hContact, info->db[j] == NULL ? proto : info->db[j], info->db[j+1], &dbv)) { if (!IsEmpty(dbv.ptszVal)) { info->OnClick(info, dbv.ptszVal); found = true; } DBFreeVariant(&dbv); } } return 0; }
// remove or display the weatehr information for a contact // hContact - the contact in which the info is going to be removed void DBDataManage(HANDLE hContact, WORD Mode, WPARAM wParam, LPARAM lParam) { DBCONTACTENUMSETTINGS dbces; DBVARIANT dbv; WCOUNTER wc; wc.current = 0; dbces.lParam=(LPARAM)&wc; dbces.pfnEnumProc=GetWeatherDataFromDB; dbces.szModule=WEATHERCONDITION; // get all the settings and stored them in a temporary list if(CallService(MS_DB_CONTACT_ENUMSETTINGS,(WPARAM)hContact,(LPARAM)&dbces)==-1) wc.current--; // begin deleting settings for (; --wc.current>-1;) { if (!DBGetContactSettingString(hContact, WEATHERCONDITION, wc.value[wc.current], &dbv)) { switch (Mode) { case WDBM_REMOVE: DBDeleteContactSetting(hContact, WEATHERCONDITION, wc.value[wc.current]); break; case WDBM_DETAILDISPLAY: { HWND hList = GetDlgItem((HWND)wParam, IDC_DATALIST); LV_ITEM lvi = { 0 }; // skip the "WeatherInfo" variable if (strcmp(wc.value[wc.current], "WeatherInfo") == 0 || strcmp(wc.value[wc.current], "Ignore") == 0 || wc.value[wc.current][0] == '#') { wfree(&wc.value[wc.current]); DBFreeVariant(&dbv); continue; } lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.iItem = 0; lvi.iSubItem = 0; lvi.lParam = (LPARAM)wc.current; lvi.pszText = (LPSTR)Translate(wc.value[wc.current]); lvi.iItem = ListView_InsertItemWth(hList, &lvi); lvi.pszText = dbv.pszVal; ListView_SetItemTextWth(hList, lvi.iItem, 1, lvi.pszText); break; } } DBFreeVariant(&dbv); } wfree(&wc.value[wc.current]); } }
int CIcqProto::getSettingString(HANDLE hContact, const char *szSetting, DBVARIANT *dbv) { int res = DBGetContactSettingString(hContact, m_szModuleName, szSetting, dbv); if (res) ICQFreeVariant(dbv); return res; }
static int EMailPreBuildMenu(WPARAM wParam, LPARAM) { CLISTMENUITEM mi; DBVARIANT dbv = { 0 }; char *szProto; ZeroMemory(&mi,sizeof(mi)); mi.cbSize = sizeof(mi); mi.flags = CMIM_FLAGS; szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); if (szProto == NULL || DBGetContactSettingString((HANDLE)wParam, szProto, "e-mail",& dbv)) if (DBGetContactSettingString((HANDLE)wParam, "UserInfo", "Mye-mail0", &dbv)) mi.flags = CMIM_FLAGS | CMIF_HIDDEN; CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hEMailMenuItem, (LPARAM)&mi); if (dbv.pszVal) DBFreeVariant(&dbv); return 0; }
//Protocol chain is list of integers "0".."n", with network protocol named "p" INT_PTR Proto_CallContactService(WPARAM wParam,LPARAM lParam) //note that this is ChainSend() too, due to a quirk of function definitions { CCSDATA *ccs=(CCSDATA*)lParam; int i; char str[10]; DBVARIANT dbv; INT_PTR ret; PROTOACCOUNT* pa; if ( wParam == (WPARAM)(-1)) return 1; for ( i = wParam;; i++ ) { _itoa( i, str, 10 ); if ( DBGetContactSettingString( ccs->hContact, "_Filter", str, &dbv )) break; if (( ret = CallProtoService( dbv.pszVal, ccs->szProtoService, i+1, lParam )) != CALLSERVICE_NOTFOUND ) { //chain was started, exit mir_free( dbv.pszVal ); return ret; } mir_free( dbv.pszVal ); } if ( DBGetContactSettingString( ccs->hContact, "Protocol", "p", &dbv )) return 1; pa = Proto_GetAccount( dbv.pszVal ); if ( pa == NULL || pa->ppro == NULL ) ret = 1; else { if ( pa->bOldProto ) ret = CallProtoServiceInt( ccs->hContact, dbv.pszVal, ccs->szProtoService, (WPARAM)(-1), ( LPARAM)ccs ); else ret = CallProtoServiceInt( ccs->hContact, dbv.pszVal, ccs->szProtoService, ccs->wParam, ccs->lParam ); if ( ret == CALLSERVICE_NOTFOUND ) ret = 1; } mir_free(dbv.pszVal); return ret; }
static INT_PTR SendEMailCommand(WPARAM wParam,LPARAM lParam) { DBVARIANT dbv; char *szUrl; char *szProto; szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); if(szProto==NULL || DBGetContactSettingString((HANDLE)wParam,szProto,"e-mail",&dbv)) { if(DBGetContactSettingString((HANDLE)wParam,"UserInfo","Mye-mail0",&dbv)) { MessageBox((HWND)lParam,TranslateT("User has not registered an e-mail address"),TranslateT("Send e-mail"),MB_OK); return 1; } } szUrl=(char*)mir_alloc(lstrlenA(dbv.pszVal)+8); lstrcpyA(szUrl,"mailto:"); lstrcatA(szUrl,dbv.pszVal); mir_free(dbv.pszVal); forkthread(SendEmailThread,0,szUrl); return 0; }
static int addKeyBinding(KEYBINDINGDESC *desc) { int i, len; TCHAR *sectionName; TCHAR *actionName; KeyBindingItem *item = (KeyBindingItem *)mir_alloc(sizeof(KeyBindingItem)); ZeroMemory(item, sizeof(KeyBindingItem)); if (desc->flags & KBDF_UNICODE) { #ifdef _UNICODE sectionName = mir_tstrdup(desc->ptszSection); actionName = mir_tstrdup(desc->ptszActionName); #else sectionName = u2a(desc->pwszSection); actionName = u2a(desc->pwszActionName); #endif } else { #ifdef _UNICODE sectionName = a2u(desc->pszSection); actionName = a2u(desc->pszActionName); #else sectionName = mir_tstrdup(desc->ptszSection); actionName = mir_tstrdup(desc->ptszActionName); #endif } len = _tcslen(sectionName) + _tcslen(actionName) + 2; item->fullActionName = (TCHAR *)mir_alloc(len * sizeof(TCHAR)); _tcscpy(item->fullActionName, sectionName); _tcscat(item->fullActionName, _T("/")); _tcscat(item->fullActionName, actionName); item->actionName = actionName; mir_free(sectionName); item->actionGroupName = mir_strdup(desc->pszActionGroup); item->action = desc->action; for (i = 0; i < 5; i++) { item->defaultKey[i] = desc->key[i]; item->key[i] = desc->key[i]; } item->next = keyBindingList; keyBindingList = item; if (item->next != NULL) item->next->prev = item; { DBVARIANT dbv; char *paramName = mir_t2a(item->fullActionName); if ( !DBGetContactSettingString(NULL, "KeyBindings", paramName, &dbv )) { for (i = 0; i < 5; i++) item->key[i] = 0; sscanf(dbv.pszVal, "%X,%X,%X,%X,%X", &item->key[0],&item->key[1],&item->key[2],&item->key[3],&item->key[4]); DBFreeVariant(&dbv); } mir_free(paramName); } return 0; }
void SkypeProfile_Load(SkypeProfile *pstProf) { DBVARIANT dbv; pstProf->Sex = (BYTE)DBGetContactSettingByte(NULL, SKYPE_PROTONAME, "Gender", 0); pstProf->Birthday.wYear = (WORD)DBGetContactSettingWord(NULL, SKYPE_PROTONAME, "BirthYear", 1900); pstProf->Birthday.wMonth = (WORD)DBGetContactSettingByte(NULL, SKYPE_PROTONAME, "BirthMonth", 01); pstProf->Birthday.wDay = (WORD)DBGetContactSettingByte(NULL, SKYPE_PROTONAME, "BirthDay", 01); if(!DBGetContactSettingTString(NULL,SKYPE_PROTONAME,"Nick",&dbv)) { _tcsncpy (pstProf->FullName, dbv.ptszVal, sizeof(pstProf->FullName)/sizeof(TCHAR)); DBFreeVariant(&dbv); } if(!DBGetContactSettingString(NULL,SKYPE_PROTONAME,"HomePage",&dbv)) { strncpy (pstProf->HomePage, dbv.pszVal, sizeof(pstProf->HomePage)); DBFreeVariant(&dbv); } if(!DBGetContactSettingTString(NULL,SKYPE_PROTONAME,"Province",&dbv)) { _tcsncpy (pstProf->Province, dbv.ptszVal, sizeof(pstProf->Province)/sizeof(TCHAR)); DBFreeVariant(&dbv); } if(!DBGetContactSettingTString(NULL,SKYPE_PROTONAME,"City",&dbv)) { _tcsncpy (pstProf->City, dbv.ptszVal, sizeof(pstProf->City)/sizeof(TCHAR)); DBFreeVariant(&dbv); } if(!DBGetContactSettingString(NULL,SKYPE_PROTONAME,"OfficePhone",&dbv)) { strncpy (pstProf->OfficePhone, dbv.pszVal, sizeof(pstProf->OfficePhone)); DBFreeVariant(&dbv); } if(!DBGetContactSettingString(NULL,SKYPE_PROTONAME,"HomePhone",&dbv)) { strncpy (pstProf->HomePhone, dbv.pszVal, sizeof(pstProf->HomePhone)); DBFreeVariant(&dbv); } }
INT_PTR __cdecl CYahooProto::OnSettingChanged(WPARAM wParam, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; if ((HANDLE) wParam == NULL) return 0; if (!m_bLoggedIn) return 0; if (!strcmp(cws->szModule, "CList")) { // A temporary contact has been added permanently if (!strcmp(cws->szSetting, "NotOnList")) { if (DBGetContactSettingByte((HANDLE) wParam, "CList", "Hidden", 0)) return 0; if (cws->value.type == DBVT_DELETED || (cws->value.type == DBVT_BYTE && cws->value.bVal == 0)) { DBVARIANT dbv; if ( !DBGetContactSettingString( (HANDLE) wParam, m_szModuleName, YAHOO_LOGINID, &dbv )){ DebugLog("Adding Permanently %s to list.", dbv.pszVal); AddBuddy(dbv.pszVal,GetWord((HANDLE) wParam, "yprotoid", 0), "miranda", NULL); DBFreeVariant(&dbv); } } } }else if (!strcmp(cws->szModule, m_szModuleName) && !strcmp(cws->szSetting, "ApparentMode")) { DBVARIANT dbv; DebugLog("DB Setting changed. YAHOO user's visible setting changed."); if ( !DBGetContactSettingString( (HANDLE) wParam, m_szModuleName, YAHOO_LOGINID, &dbv )){ int iAdd = (ID_STATUS_OFFLINE == DBGetContactSettingWord((HANDLE) wParam, m_szModuleName, "ApparentMode", 0)); stealth(dbv.pszVal, iAdd); DBFreeVariant(&dbv); } } return 0; }
void __cdecl CMsnProto::MsnGetAwayMsgThread(void* arg) { Sleep(150); AwayMsgInfo *inf = (AwayMsgInfo*)arg; DBVARIANT dbv; if (!DBGetContactSettingString(inf->hContact, "CList", "StatusMsg", &dbv)) { SendBroadcast(inf->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)inf->id, (LPARAM)dbv.pszVal); MSN_FreeVariant(&dbv); } else SendBroadcast(inf->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)inf->id, (LPARAM)0); mir_free(inf); }
void MirandaSkinnedDialog::getSettting(const char *name, const char *defVal, std::string &ret, bool global) { char setting[SETTING_NAME_SIZE]; getSettingName(setting, name, global); DBVARIANT dbv = {0}; if (DBGetContactSettingString(NULL, getModule(), setting, &dbv)) { ret = defVal; return; } ret = dbv.pszVal; DBFreeVariant(&dbv); }
//////////////////////////////////////////////////////////////////////////////// // Check if new user data has been filled in for specified account void gg_checknewuser(GGPROTO* gg, uin_t uin, const char* passwd) { char oldpasswd[128]; DBVARIANT dbv; uin_t olduin = (uin_t)DBGetContactSettingDword(NULL, GG_PROTO, GG_KEY_UIN, 0); oldpasswd[0] = '\0'; if (!DBGetContactSettingString(NULL, GG_PROTO, GG_KEY_PASSWORD, &dbv)) { if (dbv.pszVal) strcpy(oldpasswd, dbv.pszVal); DBFreeVariant(&dbv); } if (uin > 0 && strlen(passwd) > 0 && (uin != olduin || strcmp(oldpasswd, passwd))) gg->check_first_conn = 1; }
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); }
static void LoadGroups(vector<ExtraIconGroup *> &groups) { unsigned int count = DBGetContactSettingWord(NULL, MODULE_NAME "Groups", "Count", 0); for (unsigned int i = 0; i < count; ++i) { char setting[512]; mir_snprintf(setting, MAX_REGS(setting), "%d_count", i); unsigned int items = DBGetContactSettingWord(NULL, MODULE_NAME "Groups", setting, 0); if (items < 1) continue; mir_snprintf(setting, MAX_REGS(setting), "__group_%d", i); ExtraIconGroup *group = new ExtraIconGroup(setting); for (unsigned int j = 0; j < items; ++j) { mir_snprintf(setting, MAX_REGS(setting), "%d_%d", i, j); DBVARIANT dbv = { 0 }; if (!DBGetContactSettingString(NULL, MODULE_NAME "Groups", setting, &dbv)) { if (!IsEmpty(dbv.pszVal)) { BaseExtraIcon *extra = GetExtraIconByName(dbv.pszVal); if (extra != NULL) { group->items.push_back(extra); if (extra->getSlot() >= 0) group->setSlot(extra->getSlot()); } } DBFreeVariant(&dbv); } } if (group->items.size() < 2) { delete group; continue; } groups.push_back(group); } }
static int ProtocolAck(WPARAM wParam,LPARAM lParam) { ACKDATA *ack=(ACKDATA*)lParam; if (ack->type==ACKTYPE_AWAYMSG && ack->lParam) { DBVARIANT dbv; if (!DBGetContactSettingString(ack->hContact, "CList", "StatusMsg", &dbv)) { if (!strcmp(dbv.pszVal, (char *)ack->lParam)) { DBFreeVariant(&dbv); return 0; } DBFreeVariant(&dbv); } if ( DBGetContactSettingByte(NULL,"CList","ShowStatusMsg",0) || DBGetContactSettingByte(ack->hContact,"CList","StatusMsgAuto",0)) DBWriteContactSettingString(ack->hContact, "CList", "StatusMsg", (char *)ack->lParam); } return 0; }
int FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam) { HANDLE hContact = reinterpret_cast<HANDLE>(wParam); DBVARIANT dbv; if( wParam != 0 && !DBGetContactSettingString(hContact,m_szModuleName,"Homepage",&dbv) ) { CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(dbv.pszVal)); DBFreeVariant(&dbv); } else { // self contact, probably // TODO: why isn't wParam == 0 when is status menu moved to main menu? CallService(MS_UTILS_OPENURL,1,reinterpret_cast<LPARAM>(FACEBOOK_URL_PROFILE)); return 0; } return 0; }
TCHAR* CJabberProto::JGetStringCrypt( HANDLE hContact, char* valueName ) { DBVARIANT dbv; if (DBGetContactSettingString( hContact, m_szModuleName, valueName, &dbv )) return NULL; sttCryptString(dbv.pszVal); #ifdef UNICODE WCHAR *res = mir_utf8decodeW(dbv.pszVal); #else mir_utf8decode(dbv.pszVal, NULL); char *res = mir_strdup(dbv.pszVal); #endif DBFreeVariant(&dbv); return res; }
int __cdecl CYahooProto::SendMsg( HANDLE hContact, int flags, const char* pszSrc ) { DBVARIANT dbv; char *msg; int bANSI; bANSI = 0;/*GetByte( "DisableUTF8", 0 );*/ if (!m_bLoggedIn) {/* don't send message if we not connected! */ YForkThread( &CYahooProto::im_sendackfail, hContact ); return 1; } if (bANSI) /* convert to ANSI */ msg = ( char* )pszSrc; else if ( flags & PREF_UNICODE ) /* convert to utf8 */ msg = mir_utf8encodeW(( wchar_t* )&pszSrc[ strlen(pszSrc)+1 ] ); else if ( flags & PREF_UTF ) msg = mir_strdup(( char* )pszSrc ); else msg = mir_utf8encode(( char* )pszSrc ); if (lstrlenA(msg) > 800) { YForkThread( &CYahooProto::im_sendackfail_longmsg, hContact ); return 1; } if (!DBGetContactSettingString( hContact, m_szModuleName, YAHOO_LOGINID, &dbv)) { send_msg(dbv.pszVal, GetWord( hContact, "yprotoid", 0), msg, (!bANSI) ? 1 : 0); if (!bANSI) mir_free(msg); YForkThread( &CYahooProto::im_sendacksuccess, hContact ); DBFreeVariant(&dbv); return 1; } return 0; }
HANDLE find_contact(char *name) { char *szProto; int tCompareResult; HANDLE hContact; DBVARIANT dbv; // already on list? for (hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);hContact != NULL;hContact=(HANDLE)CallService( MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) { szProto = (char*)CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0 ); if (szProto!=NULL && !strcmp(szProto, SKYPE_PROTONAME) && DBGetContactSettingByte(hContact, SKYPE_PROTONAME, "ChatRoom", 0)==0) { if (DBGetContactSettingString(hContact, SKYPE_PROTONAME, SKYPE_NAME, &dbv)) continue; tCompareResult = strcmp(dbv.pszVal, name); DBFreeVariant(&dbv); if (tCompareResult) continue; return hContact; // already there, return handle } } return NULL; }
void TwitterProto::UpdateAvatarWorker(void *p) { if(p == 0) return; std::auto_ptr<update_avatar> data( static_cast<update_avatar*>(p) ); DBVARIANT dbv; if(DBGetContactSettingString(data->hContact,m_szModuleName,TWITTER_KEY_UN,&dbv)) return; std::string ext = data->url.substr(data->url.rfind('.')); std::string filename = GetAvatarFolder() + '\\' + dbv.pszVal + ext; DBFreeVariant(&dbv); PROTO_AVATAR_INFORMATION ai = {sizeof(ai)}; ai.hContact = data->hContact; ai.format = ext_to_format(ext); strncpy(ai.filename,filename.c_str(),MAX_PATH); LOG("***** Updating avatar: %s",data->url.c_str()); WaitForSingleObjectEx(avatar_lock_,INFINITE,true); if(CallService(MS_SYSTEM_TERMINATED,0,0)) { LOG("***** Terminating avatar update early: %s",data->url.c_str()); return; } if(save_url(hAvatarNetlib_,data->url,filename)) { DBWriteContactSettingString(data->hContact,m_szModuleName,TWITTER_KEY_AV_URL, data->url.c_str()); ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_AVATAR, ACKRESULT_SUCCESS,&ai,0); } else ProtoBroadcastAck(m_szModuleName,data->hContact,ACKTYPE_AVATAR, ACKRESULT_FAILED, &ai,0); ReleaseMutex(avatar_lock_); LOG("***** Done avatar: %s",data->url.c_str()); }
INT_PTR __cdecl CYahooProto::SendNudge(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE) wParam; DebugLog("[YAHOO_SENDNUDGE]"); if (!m_bLoggedIn) {/* don't send nudge if we not connected! */ YForkThread( &CYahooProto::im_sendackfail, hContact ); return 1; } DBVARIANT dbv; if (!DBGetContactSettingString(hContact, m_szModuleName, YAHOO_LOGINID, &dbv)) { send_msg(dbv.pszVal, GetWord(hContact, "yprotoid", 0), "<ding>", 0); DBFreeVariant(&dbv); YForkThread( &CYahooProto::im_sendacksuccess, hContact ); return 1; } return 0; }