static INT_PTR CALLBACK FirstRunDlgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM) createDefaultOverlayedIcon(TRUE)); SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM) createDefaultOverlayedIcon(FALSE)); TranslateDialogDefault(hwnd); CheckDlgButton(hwnd, IDC_MIR_PROTO, BST_CHECKED); break; } case WM_COMMAND: { switch(LOWORD(wParam)) { case IDOK: { int ret = 0; if (IsDlgButtonChecked(hwnd, IDC_MIR_SAME)) ret = IDC_MIR_SAME; else if (IsDlgButtonChecked(hwnd, IDC_MIR_PROTO)) ret = IDC_MIR_PROTO; else if (IsDlgButtonChecked(hwnd, IDC_MIR_SHORT)) ret = IDC_MIR_SHORT; else if (IsDlgButtonChecked(hwnd, IDC_SHORT)) ret = IDC_SHORT; else if (IsDlgButtonChecked(hwnd, IDC_DUP)) ret = IDC_DUP; EndDialog(hwnd, ret); return TRUE; } } break; } case WM_CLOSE: { EndDialog(hwnd, 0); return TRUE; } } return FALSE; }
static void IcoLibUpdateMenus() { CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS | CMIM_ICON; mi.hIcon = createDefaultOverlayedIcon(FALSE); Menu_ModifyItem(hMenu, &mi); DestroyIcon(mi.hIcon); }
static int ModulesLoaded(WPARAM wParam, LPARAM lParam) { mir_sntprintf(basedir, MAX_REGS(basedir), _T("%s\\Avatars History"), profilePath); hFolder = FoldersRegisterCustomPathT(LPGEN("Avatars"), LPGEN("Avatar History"), PROFILE_PATHT _T("\\") CURRENT_PROFILET _T("\\Avatars History")); InitPopups(); if (ServiceExists(MS_MC_GETPROTOCOLNAME)) metacontacts_proto = (char *) CallService(MS_MC_GETPROTOCOLNAME, 0, 0); // updater plugin support if(ServiceExists(MS_UPDATE_REGISTER)) { Update upd = {0}; char szCurrentVersion[30]; upd.cbSize = sizeof(upd); upd.szComponentName = pluginInfo.shortName; upd.szUpdateURL = UPDATER_AUTOREGISTER; upd.szBetaVersionURL = "http://code.google.com/p/pescuma/downloads/list?q=label:Plugin-AVH"; upd.szBetaChangelogURL = "http://code.google.com/p/pescuma/source/list"; #ifdef _WIN64 upd.pbBetaVersionPrefix = (BYTE *) "Avatar History (x64) "; upd.szBetaUpdateURL = "http://pescuma.googlecode.com/files/avatarhistW.%VERSION%-x64.zip"; #elif _UNICODE upd.pbBetaVersionPrefix = (BYTE *) "Avatar History (Unicode) "; upd.szBetaUpdateURL = "http://pescuma.googlecode.com/files/avatarhistW.%VERSION%.zip"; #else upd.pbBetaVersionPrefix = (BYTE *) "Avatar History (ANSI) "; upd.szBetaUpdateURL = "http://pescuma.googlecode.com/files/avatarhist.%VERSION%.zip"; #endif upd.cpbBetaVersionPrefix = (int) strlen((char *)upd.pbBetaVersionPrefix); upd.pbVersion = (BYTE *)CreateVersionStringPluginEx(&pluginInfo, szCurrentVersion); upd.cpbVersion = (int) strlen((char *)upd.pbVersion); CallService(MS_UPDATE_REGISTER, 0, (LPARAM)&upd); } if (DBGetContactSettingByte(NULL, MODULE_NAME, "LogToHistory", AVH_DEF_LOGTOHISTORY)) { char *templates[] = { "Avatar change\nchanged his/her avatar", "Avatar removal\nremoved his/her avatar" }; HICON hIcon = createDefaultOverlayedIcon(FALSE); HistoryEvents_RegisterWithTemplates(MODULE_NAME, "avatarchange", "Avatar change", EVENTTYPE_AVATAR_CHANGE, hIcon, HISTORYEVENTS_FORMAT_CHAR | HISTORYEVENTS_FORMAT_WCHAR | HISTORYEVENTS_FORMAT_RICH_TEXT, HISTORYEVENTS_FLAG_SHOW_IM_SRMM | HISTORYEVENTS_FLAG_EXPECT_CONTACT_NAME_BEFORE, GetHistoryEventText, templates, MAX_REGS(templates)); DestroyIcon(hIcon); } hHooks[2] = HookEvent(ME_AV_CONTACTAVATARCHANGED, AvatarChanged); return 0; }
void InitMenuItem() { CreateServiceFunction(MS_AVATARHISTORY_SHOWDIALOG, ShowDialogSvc); CMenuItem mi; mi.name.t = LPGENT("View Avatar History"); mi.flags = CMIF_TCHAR; mi.position = 1000090010; mi.hIcolibItem = createDefaultOverlayedIcon(FALSE); mi.pszService = MS_AVATARHISTORY_SHOWDIALOG; hMenu = Menu_AddContactMenuItem(&mi); DestroyIcon((HICON)mi.hIcolibItem); }
static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { HWND hwndList = GetDlgItem(hwnd, IDC_AVATARLIST); switch(uMsg) { case WM_INITDIALOG: { AvatarDialogData *data = (struct AvatarDialogData*) lParam; SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)createDefaultOverlayedIcon(TRUE)); SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)createDefaultOverlayedIcon(FALSE)); if (db_get_b(NULL, MODULE_NAME, "LogToHistory", AVH_DEF_LOGTOHISTORY)) FillAvatarListFromDB(hwndList, data->hContact); else if (opts.log_store_as_hash) FillAvatarListFromFolder(hwndList, data->hContact); else FillAvatarListFromFiles(hwndList, data->hContact); TCHAR *displayName = pcli->pfnGetContactDisplayName(data->hContact, 0); if (displayName) { TCHAR title[MAX_PATH]; mir_sntprintf(title, _countof(title), TranslateT("Avatar History for %s"), displayName); SetWindowText(hwnd, title); } SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data->hContact); UpdateAvatarPic(hwnd); CheckDlgButton(hwnd, IDC_LOGUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "LogToDisk", BST_INDETERMINATE)); CheckDlgButton(hwnd, IDC_POPUPUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "AvatarPopups", BST_INDETERMINATE)); CheckDlgButton(hwnd, IDC_HISTORYUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "LogToHistory", BST_INDETERMINATE)); ShowWindow(GetDlgItem(hwnd, IDC_OPENFOLDER), opts.log_per_contact_folders ? SW_SHOW : SW_HIDE); Utils_RestoreWindowPositionNoSize(hwnd,NULL,MODULE_NAME,"AvatarHistoryDialog"); WindowList_Add(hAvatarWindowsList,hwnd,data->hContact); TranslateDialogDefault(hwnd); EnableDisableControls(hwnd); free(data); data = NULL; } break; case WM_CLOSE: CleanupAvatarPic(hwnd); EndDialog(hwnd, 0); return TRUE; case WM_DESTROY: Utils_SaveWindowPosition(hwnd,NULL,MODULE_NAME,"AvatarHistoryDialog"); WindowList_Remove(hAvatarWindowsList,hwnd); DestroyIcon((HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0)); DestroyIcon((HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0)); { int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0); for(int i = 0; i < count; i++) delete (ListEntry*)SendMessage(hwndList, LB_GETITEMDATA, i, 0); } break; case WM_CONTEXTMENU: { HWND pic = GetDlgItem(hwnd, IDC_AVATAR); int pos; if ((HANDLE)wParam == hwndList) { POINT p = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; ScreenToClient(hwndList, &p); pos = SendMessage(hwndList, LB_ITEMFROMPOINT, 0, MAKELONG(p.x, p.y)); if (HIWORD(pos)) break; pos = LOWORD(pos); int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0); if (pos >= count) break; SendMessage(hwndList, LB_SETCURSEL, pos, 0); EnableDisableControls(hwnd); } else if ((HANDLE) wParam == pic) { pos = SendMessage(hwndList, LB_GETCURSEL, 0, 0); if (pos == LB_ERR) break; } else break; HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)); HMENU submenu = GetSubMenu(menu, 0); TranslateMenu(submenu); if (!UpdateAvatarPic(hwnd)) { RemoveMenu(submenu, 2, MF_BYPOSITION); RemoveMenu(submenu, 0, MF_BYPOSITION); } POINT p; p.x = LOWORD(lParam); p.y = HIWORD(lParam); int ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, p.x, p.y, 0, hwndList, NULL); DestroyMenu(menu); ListEntry *le = (ListEntry*) SendMessage(hwndList, LB_GETITEMDATA, pos, 0); MCONTACT hContact = (MCONTACT) GetWindowLongPtr(hwnd, GWLP_USERDATA); switch(ret) { case ID_AVATARLISTPOPUP_SAVEAS: ShowSaveDialog(hwnd, le->filename, hContact); break; case ID_AVATARLISTPOPUP_DELETE: { BOOL blDelete; if (le->hDbEvent) blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this history entry?\nOnly the entry in history will be deleted, bitmap file will be kept!"), TranslateT("Delete avatar log?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES; else blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this avatar shortcut?\nOnly shortcut will be deleted, bitmap file will be kept!"), TranslateT("Delete avatar log?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES; if (blDelete) { if (le->hDbEvent) db_event_delete(hContact, le->hDbEvent); else DeleteFile(le->filelink); delete le; SendMessage(hwndList, LB_DELETESTRING, pos, 0); int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0); if (count > 0) { if (pos >= count) pos = count -1; SendMessage(hwndList, LB_SETCURSEL, pos, 0); } UpdateAvatarPic(hwnd); EnableDisableControls(hwnd); } } break; case ID_AVATARLISTPOPUP_DELETE_BOTH: BOOL blDelete; if (le->hDbEvent) blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this archived avatar?\nThis will delete the history entry and the bitmap file.\nWARNING:This can affect more than one entry in history!"), TranslateT("Delete avatar?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES; else blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this archived avatar?\nThis will delete the shortcut and the bitmap file.\nWARNING:This can affect more than one shortcut!"), TranslateT("Delete avatar?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES; if (blDelete) { DeleteFile(le->filename); if (le->hDbEvent) db_event_delete(hContact, le->hDbEvent); else DeleteFile(le->filelink); delete le; SendMessage(hwndList, LB_DELETESTRING, pos, 0); int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0); if (count > 0) { if (pos >= count) pos = count -1; SendMessage(hwndList, LB_SETCURSEL, pos, 0); } UpdateAvatarPic(hwnd); EnableDisableControls(hwnd); } } } break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: if (HIWORD(wParam) == BN_CLICKED) { MCONTACT hContact = (MCONTACT) GetWindowLongPtr(hwnd, GWLP_USERDATA); db_set_b(hContact, MODULE_NAME, "AvatarPopups", (BYTE) IsDlgButtonChecked(hwnd, IDC_POPUPUSER)); db_set_b(hContact, MODULE_NAME, "LogToDisk", (BYTE) IsDlgButtonChecked(hwnd, IDC_LOGUSER)); db_set_b(hContact, MODULE_NAME, "LogToHistory", (BYTE) IsDlgButtonChecked(hwnd, IDC_HISTORYUSER)); CleanupAvatarPic(hwnd); EndDialog(hwnd, 0); return TRUE; } break; case IDC_AVATARLIST: if (HIWORD(wParam) == LBN_SELCHANGE) { UpdateAvatarPic(hwnd); EnableDisableControls(hwnd); return TRUE; } break; case IDC_OPENFOLDER: if (HIWORD(wParam) == BN_CLICKED && opts.log_per_contact_folders) { TCHAR avfolder[MAX_PATH]; MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); GetContactFolder(avfolder, hContact); ShellExecute(NULL, db_get_b(NULL, MODULE_NAME, "OpenFolderMethod", 0) ? _T("explore") : _T("open"), avfolder, NULL, NULL, SW_SHOWNORMAL); return TRUE; } break; case IDC_NEXT: if (HIWORD(wParam) == BN_CLICKED) { SendMessage(hwndList, LB_SETCURSEL, SendMessage(hwndList, LB_GETCURSEL, 0, 0) +1, 0); UpdateAvatarPic(hwnd); EnableDisableControls(hwnd); return TRUE; } break; case IDC_BACK: if (HIWORD(wParam) == BN_CLICKED) { int cursel = SendMessage(hwndList, LB_GETCURSEL, 0, 0); if (cursel == LB_ERR) SendMessage(hwndList, LB_SETCURSEL, SendMessage(hwndList, LB_GETCOUNT, 0, 0) -1, 0); else SendMessage(hwndList, LB_SETCURSEL, cursel -1, 0); UpdateAvatarPic(hwnd); EnableDisableControls(hwnd); return TRUE; } } break; } return FALSE; }