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; }
int ModeChange(WPARAM, LPARAM lparam) { ACKDATA *ack = (ACKDATA *)lparam; if (ack->type != ACKTYPE_STATUS || ack->result != ACKRESULT_SUCCESS || ack->hContact != NULL) return 0; courProtoName = (char *)ack->szModule; if (!IsWatchedProtocol(courProtoName) && strncmp(courProtoName, "MetaContacts", 12)) return 0; DBWriteTimeTS(time(NULL), NULL); // isetting=CallProtoService(ack->szModule,PS_GETSTATUS,0,0); WORD isetting = (WORD)ack->lParam; if (isetting < ID_STATUS_OFFLINE) isetting = ID_STATUS_OFFLINE; if ((isetting > ID_STATUS_OFFLINE) && ((WORD)ack->hProcess <= ID_STATUS_OFFLINE)) { //we have just loged-in db_set_dw(NULL, "UserOnline", ack->szModule, GetTickCount()); if (!Miranda_Terminated() && IsWatchedProtocol(ack->szModule)) { logthread_info *info = (logthread_info *)mir_alloc(sizeof(logthread_info)); mir_strncpy(info->sProtoName, courProtoName, _countof(info->sProtoName)); info->hContact = 0; info->currStatus = 0; mir_forkthread(cleanThread, info); } } else if ((isetting == ID_STATUS_OFFLINE) && ((WORD)ack->hProcess > ID_STATUS_OFFLINE)) { //we have just loged-off if (IsWatchedProtocol(ack->szModule)) { char str[MAXMODULELABELLENGTH + 9]; time_t t; time(&t); mir_snprintf(str, "OffTime-%s", ack->szModule); db_set_dw(NULL, S_MOD, str, t); } } if (isetting == db_get_w(NULL, S_MOD, courProtoName, ID_STATUS_OFFLINE)) return 0; db_set_w(NULL, S_MOD, courProtoName, isetting); if (g_bFileActive) FileWrite(NULL); courProtoName = NULL; return 0; }
int BuildContactMenu(WPARAM wparam,LPARAM lparam) { CLISTMENUITEM cmi; DBVARIANT dbv; int id=-1,isetting; HANDLE hContact; char *szProto; hContact = (HANDLE)wparam; szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); ZeroMemory(&cmi,sizeof(cmi)); cmi.cbSize=sizeof(cmi); if(!IsWatchedProtocol(szProto) || !DBGetContactSettingByte(NULL,S_MOD,"MenuItem",1)) { cmi.flags=CMIM_FLAGS|CMIF_HIDDEN; } else { cmi.flags=CMIM_NAME|CMIM_FLAGS|CMIM_ICON; cmi.hIcon=NULL; cmi.pszName=ParseString(!DBGetContactSetting(NULL,S_MOD,"MenuStamp",&dbv)?dbv.pszVal:DEFAULT_MENUSTAMP,(HANDLE)wparam,0); if(!strcmp(cmi.pszName,Translate("<unknown>"))) { if (IsWatchedProtocol(szProto)) cmi.flags|=CMIF_GRAYED; else cmi.flags|=CMIF_HIDDEN; } else if(DBGetContactSettingByte(NULL,S_MOD,"ShowIcon",1)) { isetting=DBGetContactSettingWord((HANDLE)hContact,S_MOD,"StatusTriger",-1); cmi.hIcon=LoadSkinnedProtoIcon(szProto,isetting|0x8000); } } CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hmenuitem,(LPARAM)&cmi); DBFreeVariant(&dbv); return 0; }
int UserinfoInit(WPARAM wparam,LPARAM lparam) { char *proto = GetContactProto((HANDLE)lparam); if ( IsWatchedProtocol(proto)) { OPTIONSDIALOGPAGE uip = { sizeof(uip) }; uip.hInstance = hInstance; uip.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO); uip.flags = ODPF_TCHAR; uip.ptszTitle = LPGENT("Last seen"); uip.pfnDlgProc = UserinfoDlgProc; UserInfo_AddPage(wparam, &uip); } return 0; }
int UserinfoInit(WPARAM wparam,LPARAM lparam) { char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,lparam,0); if (IsWatchedProtocol(proto)){ OPTIONSDIALOGPAGE uip; ZeroMemory(&uip,sizeof(uip)); uip.cbSize=sizeof(uip); uip.hInstance=hInstance; uip.pszTemplate=MAKEINTRESOURCE(IDD_USERINFO); uip.pszTitle="Last seen"; uip.pfnDlgProc=UserinfoDlgProc; CallService(MS_USERINFO_ADDPAGE,wparam,(LPARAM)&uip); } return 0; }
int UpdateValues(WPARAM hContact, LPARAM lparam) { // to make this code faster if (!hContact) return 0; DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lparam; char *szProto = GetContactProto(hContact); if (cws->value.type == DBVT_DWORD && !strcmp(cws->szSetting, "LastSeen") && !mir_strcmp(cws->szModule, szProto)) { DBWriteTimeTS(cws->value.dVal, hContact); HWND hwnd = WindowList_Find(g_pUserInfo, hContact); if (hwnd != NULL) SendMessage(hwnd, WM_REFRESH_UI, hContact, 0); return 0; } BOOL isIdleEvent = includeIdle ? (strcmp(cws->szSetting, "IdleTS") == 0) : 0; if (strcmp(cws->szSetting, "Status") && strcmp(cws->szSetting, "StatusTriger") && (isIdleEvent == 0)) return 0; if (!strcmp(cws->szModule, S_MOD)) { // here we will come when Settings/SeenModule/StatusTriger is changed WORD prevStatus = db_get_w(hContact, S_MOD, "OldStatus", ID_STATUS_OFFLINE); if (includeIdle) { if (db_get_b(hContact, S_MOD, "OldIdle", 0)) prevStatus &= 0x7FFF; else prevStatus |= 0x8000; } if ((cws->value.wVal | 0x8000) <= ID_STATUS_OFFLINE) { // avoid repeating the offline status if ((prevStatus | 0x8000) <= ID_STATUS_OFFLINE) return 0; db_set_b(hContact, S_MOD, "Offline", 1); { char str[MAXMODULELABELLENGTH + 9]; mir_snprintf(str, "OffTime-%s", szProto); DWORD t = db_get_dw(NULL, S_MOD, str, 0); if (!t) t = time(NULL); DBWriteTimeTS(t, hContact); } if (!db_get_b(NULL, S_MOD, "IgnoreOffline", 1)) { if (g_bFileActive) FileWrite(hContact); char *sProto = GetContactProto(hContact); if (CallProtoService(sProto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE) { myPlaySound(hContact, ID_STATUS_OFFLINE, prevStatus); if (db_get_b(NULL, S_MOD, "UsePopups", 0)) ShowPopup(hContact, sProto, ID_STATUS_OFFLINE); } if (db_get_b(NULL, S_MOD, "KeepHistory", 0)) HistoryWrite(hContact); if (db_get_b(hContact, S_MOD, "OnlineAlert", 0)) ShowHistory(hContact, 1); } } else { if (cws->value.wVal == prevStatus && !db_get_b(hContact, S_MOD, "Offline", 0)) return 0; DBWriteTimeTS(time(NULL), hContact); if (g_bFileActive) FileWrite(hContact); if (prevStatus != cws->value.wVal) myPlaySound(hContact, cws->value.wVal, prevStatus); if (db_get_b(NULL, S_MOD, "UsePopups", 0)) if (prevStatus != cws->value.wVal) ShowPopup(hContact, GetContactProto(hContact), cws->value.wVal | 0x8000); if (db_get_b(NULL, S_MOD, "KeepHistory", 0)) HistoryWrite(hContact); if (db_get_b(hContact, S_MOD, "OnlineAlert", 0)) ShowHistory(hContact, 1); db_set_b(hContact, S_MOD, "Offline", 0); } } else if (hContact && IsWatchedProtocol(cws->szModule) && !db_get_b(hContact, cws->szModule, "ChatRoom", false)) { // here we will come when <User>/<module>/Status is changed or it is idle event and if <module> is watched if (CallProtoService(cws->szModule, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE) { mir_cslock lck(csContacts); logthread_info *p = arContacts.find((logthread_info*)&hContact); if (p == NULL) { p = (logthread_info*)mir_calloc(sizeof(logthread_info)); p->hContact = hContact; mir_strncpy(p->sProtoName, cws->szModule, _countof(p->sProtoName)); arContacts.insert(p); mir_forkthread(waitThread, p); } p->currStatus = isIdleEvent ? db_get_w(hContact, cws->szModule, "Status", ID_STATUS_OFFLINE) : cws->value.wVal; } } return 0; }