void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) { for (auto &hContact : Contacts()) { char *proto = GetContactProto(hContact); if (proto && (db_get_b(hContact, proto, "ChatRoom", 0) == 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) && isContactGoneFor(hContact, options.iAbsencePeriod2) && (db_get_b(hContact, MODULENAME, "StillAbsentNotified", 0) == 0)) { db_set_b(hContact, MODULENAME, "StillAbsentNotified", 1); Skin_PlaySound("buddyExpectatorStillAbsent"); wchar_t* message = TranslateT("has not returned after a long absence."); time_t tmpTime; wchar_t tmpBuf[251] = { 0 }; tmpTime = getLastSeen(hContact); if (tmpTime != -1) { wcsftime(tmpBuf, 250, TranslateT("has not returned after being absent since %#x"), gmtime(&tmpTime)); message = tmpBuf; } else { tmpTime = getLastInputMsg(hContact); if (tmpTime != -1) { wcsftime(tmpBuf, 250, TranslateT("has not returned after being absent since %#x"), gmtime(&tmpTime)); message = tmpBuf; } } GoneNotify(hContact, message); } } }
static INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); for (auto &it : settings) LoadDBCheckState(hwndDlg, it.idCtrl, it.szSetName, it.defValue); break; case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) for (auto &it : settings) if (it.idCtrl == LOWORD(wParam)) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } break; case WM_NOTIFY: NMHDR * hdr = (NMHDR *)lParam; if (hdr && hdr->code == PSN_APPLY) { for (auto &it : settings) StoreDBCheckState(hwndDlg, it.idCtrl, it.szSetName); ClearFI(); RegisterIcons(); for (auto &hContact : Contacts()) OnExtraImageApply(hContact, 0); } break; } return FALSE; }
// shutdown action void ShutdownAction(void) { CriteriaStruct Criteria; Criteria.keep = KeepCriteria(db_get_b(NULL, ModuleName, "StartupShutdownKeep", 0)); Criteria.time = BuildCriteria(db_get_b(NULL, ModuleName, "StartupShutdownOlder", 0)); SweepHistoryFromContact(NULL, Criteria, FALSE); // sweep system history, keepunread==0 for (auto &hContact : Contacts()) SweepHistoryFromContact(hContact, Criteria, TRUE); // sweep contact history, keepunread==1 }
static void ProcessUnreadEvents(void) { for (auto &hContact : Contacts()) { for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) { DBEVENTINFO dbei = {}; db_event_get(hDbEvent, &dbei); if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && dbei.eventType == EVENTTYPE_CONTACTS) { //process the event HookDBEventAdded(hContact, (LPARAM)hDbEvent); } } } }
int main(){ int i = 0; printf("Priorbank welcomes you!\n1 - Budget\n2 - Currency for today\n3 - Profit\n4 - Maximum profit\n5 - Contacts\n0 - Exit\n"); while(i == 0){ char CHECK; scanf("%c",&CHECK); switch(CHECK){ case FN_Budget:{ printf("Enter you budget in BYR:"); scanf("%d",&SBYR); Budget(SBYR); break; } case FN_Currency:{ Currency(); break; } case FN_Profit:{ if (ch){ Profit(); break; } else break; } case FN_Mprofit:{ if (ch){ MaxProf(); break; }else break; } case FM_Contacts:{ Contacts(); break; } case FN_Exit: return 0; default: {printf("Error, enter correct value\n"); break;} } while(getchar() != '\n'); } return 0; }
MCONTACT find_contact(const char* userid, const char* protocol) { for (auto &hContact : Contacts()) { const char *proto = GetContactProto(hContact); if(proto && mir_strcmp(proto, protocol) == 0) { char *name = contact_get_id(hContact); if(name && mir_strcmp(name, userid) == 0) { mir_free(name); return hContact; } mir_free(name); } } return 0; }
static INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); TranslateDialogDefault(hwnd); wchar_t msg[MSG_SIZE], name[NAME_SIZE]; GetContactName((MCONTACT)lParam, nullptr, name, _countof(name)); mir_snwprintf(msg, TranslateT("Add module to \"%s\""), name); SetWindowText(hwnd, msg); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: if (GetWindowTextLength(GetDlgItem(hwnd, IDC_MODNAME))) { char modulename[FLD_SIZE]; GetDlgItemTextA(hwnd, IDC_MODNAME, modulename, _countof(modulename)); if (IsDlgButtonChecked(hwnd, CHK_ADD2ALL)) { // null contact db_set_b(NULL, modulename, "(Default)", 0); for (auto &hContact : Contacts()) db_set_b(hContact, modulename, "(Default)", 0); } else db_set_b((MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA), modulename, "(Default)", 0); refreshTree(1); } __fallthrough; case IDCANCEL: DestroyWindow(hwnd); break; } } return 0; }
int CMPlugin::Load() { InitOptions(); CreateServiceFunction("BuddyExpectator/actionReturned", ContactReturnedAction); CreateServiceFunction("BuddyExpectator/actionStillAbsent", ContactStillAbsentAction); CreateServiceFunction("BuddyExpectator/actionMissYou", MissYouAction); CreateServiceFunction("BuddyExpectator/actionMissYouClick", MenuMissYouClick); HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SettingChanged); HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown); HookEvent(ME_DB_CONTACT_ADDED, ContactAdded); // ensure all contacts are timestamped DBVARIANT dbv; DWORD current_time = (DWORD)time(0); for (auto &hContact : Contacts()) { if (!db_get(hContact, MODULENAME, "CreationTime", &dbv)) db_free(&dbv); else db_set_dw(hContact, MODULENAME, "CreationTime", current_time); } g_plugin.registerIcon("BuddyExpectator", iconList); HookEvent(ME_SKIN2_ICONSCHANGED, onIconsChanged); onIconsChanged(0, 0); hExtraIcon = ExtraIcon_RegisterIcolib("buddy_exp", LPGEN("Buddy Expectator"), "enabled_icon"); return 0; }