void SetStatusBarResultInfo(HWND hwndDlg) { HWND hwndStatus = GetDlgItem(hwndDlg, IDC_STATUSBAR); HWND hwndResults = GetDlgItem(hwndDlg, IDC_RESULTS); LV_ITEM lvi; struct ListSearchResult *lsr; struct ProtoResultsSummary *subtotal = NULL; int subtotalCount = 0; int i, total; TCHAR str[256]; total = ListView_GetItemCount(hwndResults); for (lvi.iItem = total-1;lvi.iItem>=0;lvi.iItem--) { lvi.mask = LVIF_PARAM; ListView_GetItem(hwndResults, &lvi); lsr = (struct ListSearchResult*)lvi.lParam; if (lsr == NULL) continue; for (i=0;i<subtotalCount;i++) { if (subtotal[i].szProto == lsr->szProto) { subtotal[i].count++; break; } } if (i == subtotalCount) { subtotal = (struct ProtoResultsSummary*)mir_realloc(subtotal, sizeof(struct ProtoResultsSummary)*(subtotalCount+1)); subtotal[subtotalCount].szProto = lsr->szProto; subtotal[subtotalCount++].count = 1; } } if (total != 0) { TCHAR substr[64]; PROTOACCOUNT *pa = Proto_GetAccount(subtotal[0].szProto); if (pa == NULL) return; if (subtotalCount == 1) { if (total == 1) mir_sntprintf(str, SIZEOF(str), TranslateT("1 %s user found"), pa->tszAccountName); else mir_sntprintf(str, SIZEOF(str), TranslateT("%d %s users found"), total, pa->tszAccountName); } else { mir_sntprintf(str, SIZEOF(str), TranslateT("%d users found ("), total); for (i=0; i < subtotalCount; i++) { if (i) { if ((pa = Proto_GetAccount(subtotal[i].szProto)) == NULL) return; lstrcat(str, _T(", ")); } mir_sntprintf(substr, SIZEOF(substr), _T("%d %s"), subtotal[i].count, pa->tszAccountName); lstrcat(str, substr); } lstrcat(str, _T(")")); } mir_free(subtotal); } else lstrcpy(str, TranslateT("No users found")); SendMessage(hwndStatus, SB_SETTEXT, 2, (LPARAM)str); }
void CSWindow::initIcons() { PROTOACCOUNT *pdescr = Proto_GetAccount(m_protoName); if (pdescr == nullptr) return; const char *szUniqueID = Proto_GetUniqueId(m_protoName); if (szUniqueID == nullptr) return; DBVARIANT dbv; if (db_get(NULL, pdescr->szModuleName, szUniqueID, &dbv)) return; db_free(&dbv); WPARAM iNumStatuses = 0; CUSTOM_STATUS cs = { sizeof(cs) }; cs.flags = CSSF_STATUSES_COUNT; cs.wParam = &iNumStatuses; if (CallProtoService(pdescr->szModuleName, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) != 0) return; m_statusCount = (int)iNumStatuses; if (nullptr == (m_icons = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, m_statusCount, 0))) return; for (int i = 1; i <= m_statusCount; i++) { HICON hIcon = (HICON)CallProtoService(pdescr->szModuleName, PS_GETCUSTOMSTATUSICON, i, 0); if (hIcon) { ImageList_AddIcon(m_icons, hIcon); DestroyIcon(hIcon); } } }
void addProtoStatusMenuItem(char *protoName) { PROTOACCOUNT *pdescr = Proto_GetAccount(protoName); if (pdescr == nullptr || pdescr->ppro == nullptr) return; HGENMENU hRoot = Menu_GetProtocolRoot(pdescr->ppro); if (hRoot == nullptr) return; char buf[200]; mir_snprintf(buf, "CSList/ShowList/%s", protoName); if (!ServiceExists(buf)) CreateServiceFunctionParam(buf, showList, (LPARAM)protoName); CMenuItem mi(g_plugin); mi.flags = CMIF_UNICODE; mi.hIcolibItem = forms[0].hIcoLibItem; mi.name.w = MODULENAME; mi.position = 2000040000; mi.pszService = buf; mi.root = hRoot; Menu_AddStatusMenuItem(&mi); RegisterHotkeys(buf, pdescr->tszAccountName, pdescr->iOrder); }
void SetStatus(WORD code, StatusItem* item, char *szAccName) { if (code == IDCLOSE) return; PROTOACCOUNT* pdescr = Proto_GetAccount(szAccName); if (pdescr == nullptr) return; if (!ProtoServiceExists(szAccName, PS_SETCUSTOMSTATUSEX)) return; int statusToSet; CUSTOM_STATUS ics = { sizeof(CUSTOM_STATUS) }; ics.flags = CSSF_MASK_STATUS | CSSF_MASK_NAME | CSSF_MASK_MESSAGE | CSSF_UNICODE; if (code == IDC_CANCEL) { statusToSet = 0; ics.ptszName = L""; ics.ptszMessage = L""; } else if (code == IDOK && item != nullptr) { statusToSet = item->m_iIcon + 1; ics.ptszName = variables_parsedup(item->m_tszTitle, nullptr, NULL); ics.ptszMessage = variables_parsedup(item->m_tszMessage, nullptr, NULL); } else return; ics.status = &statusToSet; CallProtoService(szAccName, PS_SETCUSTOMSTATUSEX, 0, (LPARAM)&ics); }
void CSAMWindow::checkItemValidity() { COMBOBOXEXITEM cbi = { 0 }; cbi.mask = CBEIF_IMAGE; cbi.iItem = SendDlgItemMessage(m_handle, IDC_COMBO, CB_GETCURSEL, 0, 0); SendDlgItemMessage(m_handle, IDC_COMBO, CBEM_GETITEM, 0, (LPARAM)&cbi); if (m_item->m_iIcon != cbi.iImage) m_item->m_iIcon = cbi.iImage, m_bChanged = TRUE; wchar_t tszInputMessage[EXTRASTATUS_MESSAGE_LIMIT]; GetDlgItemText(m_handle, IDC_MESSAGE, tszInputMessage, _countof(tszInputMessage)); PROTOACCOUNT *pdescr = Proto_GetAccount(m_parent->m_protoName); if (pdescr == nullptr) return; WPARAM i = SendMessage(m_hCombo, CB_GETCURSEL, 0, 0) + 1; wchar_t tszTitle[100]; CUSTOM_STATUS cs = { sizeof(cs) }; cs.flags = CSSF_MASK_NAME | CSSF_DEFAULT_NAME | CSSF_UNICODE; cs.ptszName = tszTitle; cs.wParam = &i; if (CallProtoService(pdescr->szModuleName, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) == 0) mir_wstrncpy(m_item->m_tszTitle, TranslateW(tszTitle), _countof(m_item->m_tszTitle)); if (mir_wstrcmp(m_item->m_tszMessage, tszInputMessage)) mir_wstrcpy(m_item->m_tszMessage, tszInputMessage), m_bChanged = true; }
TCHAR *GetProtoName(struct ClcContact *item) { PROTOACCOUNT *acc; #ifdef UNICODE char description[128]; #endif proto_name[0] = '\0'; if (item->hContact == NULL || item->proto == NULL) { mir_tstrncpy(proto_name, TranslateT("Unknown protocol"), _countof(proto_name)); return proto_name; } acc = Proto_GetAccount(item->proto); if (acc == NULL) { #ifdef UNICODE CallProtoService(item->proto, PS_GETNAME, sizeof(description),(LPARAM) description); mir_sntprintf(proto_name, _countof(proto_name), L"%S", description); #else CallProtoService(item->proto, PS_GETNAME, sizeof(proto_name),(LPARAM) proto_name); #endif return proto_name; } mir_tstrncpy(proto_name, acc->tszAccountName, _countof(proto_name)); return proto_name; }
INT_PTR Proto_CallContactService(WPARAM wParam, LPARAM lParam) { CCSDATA *ccs = (CCSDATA*)lParam; INT_PTR ret; if (wParam == (WPARAM)(-1)) return 1; for (int i = wParam; i < filters.getCount(); i++) { if ((ret = CallProtoServiceInt(NULL, filters[i]->szName, ccs->szProtoService, i+1, lParam)) != CALLSERVICE_NOTFOUND) { //chain was started, exit return ret; } } char szProto[40]; if (GetProtocolP((MCONTACT)ccs->hContact, szProto, sizeof(szProto))) return 1; PROTOACCOUNT *pa = Proto_GetAccount(szProto); if (pa == NULL || pa->ppro == NULL) return 1; if (pa->bOldProto) ret = CallProtoServiceInt(ccs->hContact, szProto, ccs->szProtoService, (WPARAM)(-1), (LPARAM)ccs); else ret = CallProtoServiceInt(ccs->hContact, szProto, ccs->szProtoService, ccs->wParam, ccs->lParam); if (ret == CALLSERVICE_NOTFOUND) ret = 1; return ret; }
static int lua_GetProtocol(lua_State *L) { const char *name = NULL; switch (lua_type(L, 1)) { case LUA_TNUMBER: { const char *proto = GetContactProto(lua_tonumber(L, 1)); PROTOACCOUNT *pa = Proto_GetAccount(proto); if (pa) name = pa->szProtoName; } break; case LUA_TSTRING: name = lua_tostring(L, 1); break; default: luaL_argerror(L, 1, luaL_typename(L, 1)); } PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(name); if (pd) MT<PROTOCOLDESCRIPTOR>::Set(L, pd); else lua_pushnil(L); return 1; }
INT_PTR CallContactService(MCONTACT hContact, const char *szProtoService, WPARAM wParam, LPARAM lParam) { INT_PTR ret; CCSDATA ccs = { hContact, szProtoService, wParam, lParam }; for (int i=0; i < filters.getCount(); i++) { if ((ret = CallProtoServiceInt(hContact, filters[i]->szName, szProtoService, i+1, (LPARAM)&ccs)) != CALLSERVICE_NOTFOUND) { //chain was started, exit return ret; } } char szProto[40]; if ( GetProtocolP((MCONTACT)hContact, szProto, sizeof(szProto))) return 1; PROTOACCOUNT *pa = Proto_GetAccount(szProto); if (pa == NULL || pa->ppro == NULL) return 1; if (pa->bOldProto) ret = CallProtoServiceInt(hContact, szProto, szProtoService, (WPARAM)(-1), (LPARAM)&ccs); else ret = CallProtoServiceInt(hContact, szProto, szProtoService, wParam, lParam); if (ret == CALLSERVICE_NOTFOUND) ret = 1; return ret; }
int TlenProtocol::UserInfoInit(WPARAM wParam, LPARAM lParam) { if (!Proto_GetAccount(m_szModuleName)) return 0; MCONTACT hContact = (MCONTACT) lParam; char *szProto = GetContactProto(hContact); if ((szProto != NULL && !mir_strcmp(szProto, m_szModuleName)) || !lParam) { OPTIONSDIALOGPAGE odp = { 0 }; odp.hInstance = hInst; odp.flags = ODPF_TCHAR; odp.pfnDlgProc = TlenUserInfoDlgProc; odp.position = -2000000000; odp.pszTemplate = ((HANDLE)lParam != NULL) ? MAKEINTRESOURCEA(IDD_USER_INFO):MAKEINTRESOURCEA(IDD_USER_VCARD); odp.ptszTitle = (hContact != NULL) ? LPGENT("Account") : m_tszUserName; odp.dwInitParam = (LPARAM)this; UserInfo_AddPage(wParam, &odp); } if (!lParam && isOnline) { CCSDATA ccs = {0}; GetInfo(0, (LPARAM) &ccs); } return 0; }
int __forceinline GetProtoIndex(char * szName) { if (!szName) return -1; PROTOACCOUNT *pa = Proto_GetAccount(szName); return (pa == NULL) ? -1 : pa->iOrder; }
static int PrebuildContactMenu(WPARAM wParam, LPARAM) { MCONTACT hContact = wParam; if (hContact) { char *szProto = GetContactProto(hContact); PROTOACCOUNT *pa = Proto_GetAccount(szProto); Menu_ShowItem(hChangeSound, IsSuitableProto(pa)); } return 0; }
PROTOACCOUNT* __fastcall Proto_GetAccount(MCONTACT hContact) { if (hContact == NULL) return NULL; char szProto[40]; if (GetProtocolP((MCONTACT)hContact, szProto, sizeof(szProto))) return NULL; return Proto_GetAccount(szProto); }
static int OnOkToExit(WPARAM, LPARAM) { // save last protocolstatus int count; PROTOACCOUNT** protos; Proto_EnumAccounts(&count, &protos); for (int i = 0; i < count; i++) { PROTOACCOUNT *pa = protos[i]; if (!IsSuitableProto(pa)) continue; if (!Proto_GetAccount(pa->szModuleName)) continue; char lastName[128], lastMsg[128]; mir_snprintf(lastName, "%s%s", PREFIX_LAST, pa->szModuleName); db_set_w(NULL, MODULENAME, lastName, (WORD)CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0)); mir_snprintf(lastMsg, "%s%s", PREFIX_LASTMSG, pa->szModuleName); db_unset(NULL, MODULENAME, lastMsg); if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0) & PF1_MODEMSGSEND & ~PF1_INDIVMODEMSG)) continue; int status = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0); if (!(CallProtoService(pa->szModuleName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0) & Proto_Status2Flag(status))) continue; // NewAwaySys if (ServiceExists(MS_NAS_GETSTATE)) { NAS_PROTOINFO npi = { sizeof(npi) }; npi.szProto = pa->szModuleName; CallService(MS_NAS_GETSTATE, (WPARAM)&npi, 1); if (npi.szMsg == NULL) { npi.status = 0; npi.szProto = NULL; CallService(MS_NAS_GETSTATE, (WPARAM)&npi, 1); } if (npi.szMsg != NULL) { db_set_ts(NULL, MODULENAME, lastMsg, npi.tszMsg); mir_free(npi.tszMsg); } } } if (db_get_b(NULL, MODULENAME, SETTING_SETPROFILE, 1) || db_get_b(NULL, MODULENAME, SETTING_OFFLINECLOSE, 0)) { if (ServiceExists(MS_CLIST_SETSTATUSMODE)) CallService(MS_CLIST_SETSTATUSMODE, (WPARAM)ID_STATUS_OFFLINE, 0); else log_debugA("StartupStatus: MS_CLIST_SETSTATUSMODE not available!"); } return 0; }
int IsWatchedProtocol(const char* szProto) { if (szProto == NULL) return 0; PROTOACCOUNT *pd = Proto_GetAccount(szProto); if (pd == NULL || CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_2, 0) == 0) return 0; return arWatchedProtos.find((char*)szProto) != NULL; }
/** * name: DisplayNameToFileName * desc: convert contact's display name to valid filename * param: hContact - handle of contact to create the filename for * pszFileName - buffer, retrieving the converted filename * cchFileName - number of maximum characters the filename can be * return: nothing **/ static void DisplayNameToFileName(lpExImParam ExImContact, LPSTR pszFileName, WORD cchFileName) { LPCSTR disp = 0; LPSTR temp = 0; cchFileName--; pszFileName[0] = 0; switch (ExImContact->Typ) { case EXIM_ALL: case EXIM_GROUP: mir_strncpy(pszFileName, Translate("all Contacts"), cchFileName); return; case EXIM_CONTACT: if (ExImContact->hContact == NULL) { mir_strncpy(pszFileName, Translate("Owner"), cchFileName); return; } disp = temp = mir_t2a(pcli->pfnGetContactDisplayName(ExImContact->hContact, NULL)); break; case EXIM_SUBGROUP: temp = mir_t2a(ExImContact->ptszName); disp = temp; break; case EXIM_ACCOUNT: PROTOACCOUNT* acc = Proto_GetAccount(ExImContact->pszName); disp = temp = mir_t2a(acc->tszAccountName); break; } // replace unwanted characters while (*disp != 0 && cchFileName > 1) { switch (*disp) { case '?': case '*': case ':': case '\\': case '|': case '/': case '<': case '>': case '"': *(pszFileName++) = '_'; break; default: *(pszFileName++) = *disp; break; } disp++; cchFileName--; } mir_free(temp); pszFileName[0] = 0; }
static INT_PTR CallRecvChain(WPARAM wParam,LPARAM lParam) { CCSDATA *ccs=(CCSDATA*)lParam; int i; INT_PTR ret; char str[10]; DBVARIANT dbv; PROTOACCOUNT* pa; if ( wParam == (WPARAM)(-1)) return 1; //shouldn't happen - sanity check if ( wParam == 0 ) { //begin processing by finding end of chain for( ;;wParam++ ) { _itoa( wParam, str, 10 ); if ( DBGetContactSettingString( ccs->hContact, "_Filter", str, &dbv )) break; mir_free(dbv.pszVal); } } else wParam--; for ( i = wParam-1; i >= 0; i-- ) { _itoa( i, str, 10 ); if ( DBGetContactSettingString( ccs->hContact, "_Filter", str, &dbv )) //never happens return 1; 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 ); } //end of chain, call network protocol again 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; }
XCHAR *GetInternalVariable(const XCHAR *key, size_t keyLength, MCONTACT hContact) { XCHAR *theValue = NULL; XCHAR *theKey = (XCHAR *)_alloca(sizeof(XCHAR) * (keyLength + 1)); _xcsncpy(theKey, key, keyLength); theKey[keyLength] = 0; if (hContact) { if (!_xcscmp(theKey, XSTR(key, "nick"))) theValue = GetContactNickX(key, hContact); else if (!_xcscmp(theKey, XSTR(key, "proto"))) theValue = mir_a2x(key, GetContactProto(hContact)); else if (!_xcscmp(theKey, XSTR(key, "accountname"))) { PROTOACCOUNT *acc = Proto_GetAccount(GetContactProto(hContact)); if (acc != NULL) theValue = mir_a2x(key, _T2A(acc->tszAccountName)); } else if (!_xcscmp(theKey, XSTR(key, "userid"))) theValue = GetContactIDX(key, hContact); } if (!theValue) { if (!_xcscmp(theKey, XSTR(key, "miranda_path"))) theValue = GetModulePathX(key, NULL); else if (!_xcscmp(theKey, XSTR(key, "appdata"))) theValue = SHGetSpecialFolderPathX(CSIDL_APPDATA, theKey); else if (!_xcscmp(theKey, XSTR(key, "mydocuments"))) theValue = SHGetSpecialFolderPathX(CSIDL_PERSONAL, theKey); else if (!_xcscmp(theKey, XSTR(key, "desktop"))) theValue = SHGetSpecialFolderPathX(CSIDL_DESKTOPDIRECTORY, theKey); else if (!_xcscmp(theKey, XSTR(key, "miranda_profilesdir"))) theValue = GetProfileDirX(key); else if (!_xcscmp(theKey, XSTR(key, "miranda_profilename"))) theValue = GetProfileNameX(key); else if (!_xcscmp(theKey, XSTR(key, "username"))) theValue = GetUserNameX(key); else if (!_xcscmp(theKey, XSTR(key, "miranda_avatarcache"))) theValue = GetPathVarX(key, 1); else if (!_xcscmp(theKey, XSTR(key, "miranda_logpath"))) theValue = GetPathVarX(key, 2); else if (!_xcscmp(theKey, XSTR(key, "miranda_userdata"))) theValue = GetPathVarX(key, 3); } if (!theValue) theValue = GetEnvironmentVariableX(theKey); return theValue; }
int fnGetProtocolVisibility(const char *accName) { if (accName) { PROTOACCOUNT *pa = Proto_GetAccount(accName); if (pa && pa->bIsVisible && Proto_IsAccountEnabled(pa) && pa->ppro) { PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(pa->szProtoName); if (pd == NULL || pd->type != PROTOTYPE_PROTOCOL) return FALSE; return (pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0)); } } return FALSE; }
int ApplyProtoFilter(MCONTACT hContact) { if (g_Mode == MODE_ALL) return 0; int loaded = 0; char szProto[FLD_SIZE]; if (!db_get_static(hContact, "Protocol", "p", szProto, _countof(szProto))) loaded = Proto_GetAccount(szProto) ? 1 : 0; if ((loaded && g_Mode == MODE_UNLOADED) || (!loaded && g_Mode == MODE_LOADED)) return 1; return 0; }
static INT_PTR Proto_AddToContact(WPARAM wParam,LPARAM lParam) { PROTOCOLDESCRIPTOR *pd,*pdCompare; pd = Proto_IsProtocolLoaded(( char* )lParam ); if ( pd == NULL ) { PROTOACCOUNT* pa = Proto_GetAccount(( char* )lParam ); if ( pa ) { DBWriteContactSettingString((HANDLE)wParam,"Protocol","p",(char*)lParam); return 0; } return 1; } if ( pd->type == PROTOTYPE_PROTOCOL ) { DBWriteContactSettingString((HANDLE)wParam,"Protocol","p",(char*)lParam); return 0; } if(Proto_IsProtoOnContact(wParam,lParam)) return 1; { /* v:0.3.3 + PROTO FILTERS ARE NOW KEPT IN THEIR OWN DB MODULE! */ int i; char str[10],*lastProto; DBVARIANT dbv; for(i=0;;i++) { _itoa(i,str,10); if(DBGetContactSettingString((HANDLE)wParam,"_Filter",str,&dbv)) break; pdCompare = Proto_IsProtocolLoaded(( char* )dbv.pszVal ); mir_free(dbv.pszVal); if(pdCompare==NULL) continue; if(pd->type > pdCompare->type) break; } //put the new module at position i lastProto=mir_strdup((char*)lParam); for(;;i++) { _itoa(i,str,10); if(DBGetContactSettingString((HANDLE)wParam,"_Filter",str,&dbv)) { DBWriteContactSettingString((HANDLE)wParam,"_Filter",str,lastProto); mir_free(lastProto); break; } DBWriteContactSettingString((HANDLE)wParam,"_Filter",str,lastProto); mir_free(lastProto); lastProto=dbv.pszVal; } } return 0; }
PROTOACCOUNT* __fastcall Proto_GetAccount(HANDLE hContact) { DBVARIANT dbv; DBCONTACTGETSETTING dbcgs; char name[32]; dbv.type = DBVT_ASCIIZ; dbv.pszVal = name; dbv.cchVal = SIZEOF(name); dbcgs.pValue = &dbv; dbcgs.szModule = "Protocol"; dbcgs.szSetting = "p"; if (CallService(MS_DB_CONTACT_GETSETTINGSTATIC, (WPARAM)hContact, (LPARAM)&dbcgs)) return 0; return Proto_GetAccount((char* )dbv.pszVal); }
static INT_PTR Proto_AddToContact(WPARAM wParam, LPARAM lParam) { char *szProto = (char*)lParam; PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(szProto); if (pd == NULL) { PROTOACCOUNT *pa = Proto_GetAccount(szProto); if (pa) { db_set_s(wParam, "Protocol", "p", szProto); return 0; } return 1; } if (pd->type == PROTOTYPE_PROTOCOL || pd->type == PROTOTYPE_VIRTUAL) db_set_s(wParam, "Protocol", "p", szProto); return 0; }
int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const char *szSearchService, DWORD requiredCapability, void *pvSearchParams) { if (szProto == NULL) { int failures = 0; dat->searchCount = 0; dat->search = (struct ProtoSearchInfo*)mir_calloc(sizeof(struct ProtoSearchInfo) * accounts.getCount()); for (int i=0; i < accounts.getCount();i++) { PROTOACCOUNT *pa = accounts[i]; if (!Proto_IsAccountEnabled(pa)) continue; DWORD caps = (DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if (!(caps&requiredCapability)) continue; dat->search[dat->searchCount].hProcess = (HANDLE)CallProtoServiceInt(NULL,pa->szModuleName, szSearchService, 0, (LPARAM)pvSearchParams); dat->search[dat->searchCount].szProto = pa->szModuleName; if (dat->search[dat->searchCount].hProcess == NULL) failures++; else dat->searchCount++; } if (failures) { //infuriatingly vague error message. fixme. if (dat->searchCount == 0) { forkthread(BeginSearchFailed, 0, NULL); mir_free(dat->search); dat->search = NULL; return 1; } } } else { dat->search = (struct ProtoSearchInfo*)mir_alloc(sizeof(struct ProtoSearchInfo)); dat->searchCount = 1; dat->search[0].hProcess = (HANDLE)CallProtoServiceInt(NULL,szProto, szSearchService, 0, (LPARAM)pvSearchParams); dat->search[0].szProto = szProto; if (dat->search[0].hProcess == NULL) { //infuriatingly vague error message. fixme. PROTOACCOUNT *pa = Proto_GetAccount(szProto); forkthread(BeginSearchFailed, 0, mir_tstrdup(pa->tszAccountName)); mir_free(dat->search); dat->search = NULL; dat->searchCount = 0; return 1; } } 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; }
int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char *pszProtoName, TCHAR*, COLORREF crBkg, const TCHAR *fmt, ...) { static TCHAR szBuf[4 * 1024]; if (!fmt || fmt[0] == 0 || mir_tstrlen(fmt) > 2000) return 0; va_list marker; va_start(marker, fmt); mir_vsntprintf(szBuf, 4096, fmt, marker); va_end(marker); POPUPDATAT pd = { 0 }; pd.lchContact = hContact; if (hIcon) pd.lchIcon = hIcon; else pd.lchIcon = LoadIconEx("window", FALSE); PROTOACCOUNT *pa = Proto_GetAccount(pszProtoName); mir_sntprintf(pd.lptzContactName, _T("%s - %s"), (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName, cli.pfnGetContactDisplayName(hContact, 0)); mir_tstrncpy(pd.lptzText, TranslateTS(szBuf), _countof(pd.lptzText)); pd.iSeconds = g_Settings->iPopupTimeout; if (g_Settings->iPopupStyle == 2) { pd.colorBack = 0; pd.colorText = 0; } else if (g_Settings->iPopupStyle == 3) { pd.colorBack = g_Settings->crPUBkgColour; pd.colorText = g_Settings->crPUTextColour; } else { pd.colorBack = g_Settings->crLogBackground; pd.colorText = crBkg; } pd.PluginWindowProc = PopupDlgProc; pd.PluginData = si; return PUAddPopupT(&pd); }
// !!!!!!!! this code is dangerous like a hell void SetStatusBarSearchInfo(HWND hwndStatus, struct FindAddDlgData *dat) { TCHAR str[256]; if (dat->searchCount != 0) { int i; lstrcpy(str, TranslateT("Searching")); for (i=0; i < dat->searchCount; i++) { PROTOACCOUNT *pa = Proto_GetAccount(dat->search[i].szProto); if (!pa) continue; lstrcat(str, i ? _T(", ") : _T(" ")); lstrcat(str, pa->tszAccountName); } } else lstrcpy(str, TranslateT("Idle")); SendMessage(hwndStatus, SB_SETTEXT, 0, (LPARAM)str); }
/** * 2nd part of the object initialization that must be callable during the * object's lifetime (not only on construction). */ void CContactCache::initPhaseTwo() { m_szAccount = 0; if (cc->szProto) { PROTOACCOUNT *acc = Proto_GetAccount(cc->szProto); if (acc && acc->tszAccountName) m_szAccount = acc->tszAccountName; } m_Valid = (cc->szProto != 0 && m_szAccount != 0) ? true : false; if (m_Valid) { m_isMeta = db_mc_isMeta(cc->contactID) != 0; // don't use cc->IsMeta() here if (m_isMeta) updateMeta(); updateState(); updateFavorite(); } else { m_szAccount = C_INVALID_ACCOUNT; m_isMeta = false; } }
static INT_PTR Proto_RecvChain(WPARAM wParam, LPARAM lParam) { CCSDATA *ccs = (CCSDATA*)lParam; INT_PTR ret; if (wParam == (WPARAM)(-1)) return 1; //shouldn't happen - sanity check if (wParam == 0) { //begin processing by finding end of chain if (GetCurrentThreadId() != hMainThreadId) // restart this function in the main thread return CallServiceSync(MS_PROTO_CHAINRECV, wParam, lParam); wParam = filters.getCount(); } else wParam--; for (int i = wParam-1; i >= 0; i--) if ((ret = CallProtoServiceInt(NULL, filters[i]->szName, ccs->szProtoService, i+1, lParam)) != CALLSERVICE_NOTFOUND) //chain was started, exit return ret; //end of chain, call network protocol again char szProto[40]; if (GetProtocolP((MCONTACT)ccs->hContact, szProto, sizeof(szProto))) return 1; PROTOACCOUNT *pa = Proto_GetAccount(szProto); if (pa == NULL || pa->ppro == NULL) return 1; if (pa->bOldProto) ret = CallProtoServiceInt(ccs->hContact, szProto, ccs->szProtoService, (WPARAM)(-1), (LPARAM)ccs); else ret = CallProtoServiceInt(ccs->hContact, szProto, ccs->szProtoService, ccs->wParam, ccs->lParam); if (ret == CALLSERVICE_NOTFOUND) ret = 1; return ret; }
void CSAMWindow::setCombo() { PROTOACCOUNT *pdescr = Proto_GetAccount(m_parent->m_protoName); if (pdescr == nullptr) return; const char *szUniqueID = Proto_GetUniqueId(pdescr->szModuleName); if (szUniqueID == nullptr) return; DBVARIANT dbv; if (db_get(NULL, pdescr->szModuleName, szUniqueID, &dbv)) return; db_free(&dbv); WPARAM iStatus; wchar_t tszName[100]; CUSTOM_STATUS cs = { sizeof(cs) }; cs.flags = CSSF_MASK_NAME | CSSF_DEFAULT_NAME | CSSF_UNICODE; cs.ptszName = tszName; cs.wParam = &iStatus; SendMessage(m_hCombo, CBEM_SETIMAGELIST, 0, (LPARAM)m_parent->m_icons); for (int i = 1; i <= m_parent->m_statusCount; i++) { iStatus = i; if (CallProtoService(pdescr->szModuleName, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) != 0) continue; COMBOBOXEXITEM cbi = { 0 }; cbi.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE; cbi.iItem = -1; cbi.iImage = cbi.iSelectedImage = i - 1; cbi.pszText = TranslateW(tszName); SendMessage(m_hCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbi); } SendMessage(m_hCombo, CB_SETCURSEL, 0, 0); // first 0 sets selection to top }