char* CIcqProto::buildUinList(int subtype, size_t wMaxLen, MCONTACT *hContactResume) { MCONTACT hContact; WORD wCurrentLen = 0; DWORD dwUIN; uid_str szUID; int add; char *szList = (char*)SAFE_MALLOC(CallService(MS_DB_CONTACT_GETCOUNT, 0, 0) * UINMAXLEN); char szLen[2]; szLen[1] = '\0'; if (*hContactResume) hContact = *hContactResume; else hContact = db_find_first(m_szModuleName); while (hContact != NULL) { if (!getContactUid(hContact, &dwUIN, &szUID)) { szLen[0] = (char)mir_strlen(strUID(dwUIN, szUID)); switch (subtype) { case BUL_VISIBLE: add = ID_STATUS_ONLINE == getWord(hContact, "ApparentMode", 0); break; case BUL_INVISIBLE: add = ID_STATUS_OFFLINE == getWord(hContact, "ApparentMode", 0); break; case BUL_TEMPVISIBLE: add = getByte(hContact, "TemporaryVisible", 0); // clear temporary flag // Here we assume that all temporary contacts will be in one packet setByte(hContact, "TemporaryVisible", 0); break; default: add = 1; // If we are in SS mode, we only add those contacts that are // not in our SS list, or are awaiting authorization, to our // client side list if (m_bSsiEnabled && getWord(hContact, DBSETTING_SERVLIST_ID, 0) && !getByte(hContact, "Auth", 0)) add = 0; // Never add hidden contacts to CS list if (db_get_b(hContact, "CList", "Hidden", 0)) add = 0; break; } if (add) { wCurrentLen += szLen[0] + 1; if (wCurrentLen > wMaxLen) { *hContactResume = hContact; return szList; } strcat(szList, szLen); strcat(szList, szUID); } } hContact = db_find_next(hContact, m_szModuleName); } *hContactResume = NULL; return szList; }
bool FrameIsFloating() { if(Frameid == -1) return true; // no frames, always floating return (CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLOATING, Frameid), 0) != 0); }
INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)lParam); if(hEmailFont) DeleteObject(hEmailFont); { LOGFONT lf; hEmailFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_EMAILS,WM_GETFONT,0,0); GetObject(hEmailFont,sizeof(lf),&lf); lf.lfUnderline=1; hEmailFont=CreateFontIndirect(&lf); } if(hHandCursor==NULL) { if(IsWinVer2000Plus()) hHandCursor=LoadCursor(NULL,IDC_HAND); else hHandCursor=LoadCursor(hMirandaInst,MAKEINTRESOURCE(IDC_HYPERLINKHAND)); } TranslateDialogDefault(hwndDlg); { LVCOLUMN lvc; RECT rc; GetClientRect(GetDlgItem(hwndDlg,IDC_EMAILS),&rc); rc.right-=GetSystemMetrics(SM_CXVSCROLL); lvc.mask=LVCF_WIDTH; ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg,IDC_EMAILS), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg,IDC_PHONES), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); lvc.cx=rc.right/4; ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS),0,&lvc); ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES),0,&lvc); lvc.cx=rc.right-rc.right/4-40; ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS),1,&lvc); lvc.cx=rc.right-rc.right/4-90; ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES),1,&lvc); lvc.cx=50; ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES),2,&lvc); lvc.cx=20; ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS),2,&lvc); ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_EMAILS),3,&lvc); ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES),3,&lvc); ListView_InsertColumn(GetDlgItem(hwndDlg,IDC_PHONES),4,&lvc); } break; case M_REMAKELISTS: { char *szProto; LVITEM lvi; int i; char idstr[33]; TCHAR idstr2[33]; DBVARIANT dbv; HANDLE hContact=(HANDLE)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); if (hContact != NULL) { szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); if (szProto==NULL) break; //e-mails ListView_DeleteAllItems(GetDlgItem(hwndDlg,IDC_EMAILS)); lvi.mask=LVIF_TEXT|LVIF_PARAM; lvi.lParam=(LPARAM)(-1); lvi.iSubItem=0; lvi.iItem=0; for(i=-1;;i++) { if(i==-1) { if(DBGetContactSettingTString(hContact,szProto,"e-mail",&dbv)) continue; lvi.pszText=TranslateT("Primary"); } else { mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", i ); if(DBGetContactSettingTString(hContact,szProto,idstr,&dbv)) break; lvi.pszText=idstr2; mir_sntprintf(idstr2, SIZEOF(idstr2), _T("%d"),i+2); } ListView_InsertItem(GetDlgItem(hwndDlg,IDC_EMAILS),&lvi); ListView_SetItemText(GetDlgItem(hwndDlg,IDC_EMAILS),lvi.iItem,1,dbv.ptszVal); DBFreeVariant(&dbv); lvi.iItem++; } lvi.iSubItem=0; for(i=0;;i++) { lvi.lParam=i; mir_snprintf(idstr, SIZEOF(idstr), "Mye-mail%d",i); if(DBGetContactSettingTString(hContact,"UserInfo",idstr,&dbv)) break; lvi.pszText=idstr2; mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"),i+1); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_EMAILS),&lvi); ListView_SetItemText(GetDlgItem(hwndDlg,IDC_EMAILS),lvi.iItem,1,dbv.ptszVal); DBFreeVariant(&dbv); lvi.iItem++; } lvi.mask=LVIF_PARAM; lvi.lParam=(LPARAM)(-2); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_EMAILS),&lvi); //phones ListView_DeleteAllItems(GetDlgItem(hwndDlg,IDC_PHONES)); lvi.mask=LVIF_TEXT|LVIF_PARAM; lvi.lParam=(LPARAM)(-1); lvi.iSubItem=0; lvi.iItem=0; if(!DBGetContactSettingTString(hContact,szProto,"Phone",&dbv)) { lvi.pszText=TranslateT("Primary"); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi); ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal); DBFreeVariant(&dbv); lvi.iItem++; } if(!DBGetContactSettingTString(hContact,szProto,"Fax",&dbv)) { lvi.pszText=TranslateT("Fax"); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi); ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal); DBFreeVariant(&dbv); lvi.iItem++; } if(!DBGetContactSettingTString(hContact,szProto,"Cellular",&dbv)) { lvi.pszText=TranslateT("Mobile"); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi); if(lstrlenA(dbv.pszVal)>4 && !lstrcmpA(dbv.pszVal+lstrlenA(dbv.pszVal)-4," SMS")) { ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,2,_T("y")); dbv.ptszVal[lstrlen(dbv.ptszVal)-4]='\0'; } ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal); DBFreeVariant(&dbv); lvi.iItem++; } if(!DBGetContactSettingTString(hContact,szProto,"CompanyPhone",&dbv)) { lvi.pszText=TranslateT("Work Phone"); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi); ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal); DBFreeVariant(&dbv); lvi.iItem++; } if(!DBGetContactSettingTString(hContact,szProto,"CompanyFax",&dbv)) { lvi.pszText=TranslateT("Work Fax"); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi); ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal); DBFreeVariant(&dbv); lvi.iItem++; } lvi.iSubItem=0; for(i=0;;i++) { lvi.lParam=i; mir_snprintf(idstr, SIZEOF(idstr), "MyPhone%d",i); if(DBGetContactSettingTString(hContact,"UserInfo",idstr,&dbv)) break; lvi.pszText=idstr2; mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"),i+1); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi); if(lstrlen(dbv.ptszVal)>4 && !lstrcmp(dbv.ptszVal+lstrlen(dbv.ptszVal)-4,_T(" SMS"))) { ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,2,_T("y")); dbv.ptszVal[lstrlen(dbv.ptszVal)-4]='\0'; } ListView_SetItemText(GetDlgItem(hwndDlg,IDC_PHONES),lvi.iItem,1,dbv.ptszVal); DBFreeVariant(&dbv); lvi.iItem++; } lvi.mask=LVIF_PARAM; lvi.lParam=(LPARAM)(-2); ListView_InsertItem(GetDlgItem(hwndDlg,IDC_PHONES),&lvi); } break; } case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_INFOCHANGED: SendMessage(hwndDlg,M_REMAKELISTS,0,0); break; } break; case IDC_EMAILS: case IDC_PHONES: switch (((LPNMHDR)lParam)->code) { case NM_CUSTOMDRAW: { NMLVCUSTOMDRAW *nm=(NMLVCUSTOMDRAW*)lParam; switch(nm->nmcd.dwDrawStage) { case CDDS_PREPAINT: case CDDS_ITEMPREPAINT: SetWindowLongPtr(hwndDlg,DWLP_MSGRESULT,CDRF_NOTIFYSUBITEMDRAW); return TRUE; case CDDS_SUBITEM|CDDS_ITEMPREPAINT: { RECT rc; ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom,nm->nmcd.dwItemSpec,nm->iSubItem,LVIR_LABEL,&rc); if(nm->iSubItem==1 && nm->nmcd.hdr.idFrom==IDC_EMAILS) { HFONT hoFont; TCHAR szText[256] = {0}; ListView_GetItemText(nm->nmcd.hdr.hwndFrom,nm->nmcd.dwItemSpec,nm->iSubItem,szText,SIZEOF(szText)); hoFont=(HFONT)SelectObject(nm->nmcd.hdc,hEmailFont); SetTextColor(nm->nmcd.hdc,RGB(0,0,255)); DrawText(nm->nmcd.hdc,szText,-1,&rc,DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_TOP); SelectObject(nm->nmcd.hdc,hoFont); SetWindowLongPtr(hwndDlg,DWLP_MSGRESULT,CDRF_SKIPDEFAULT); return TRUE; } HICON hIcon = NULL; if(nm->nmcd.lItemlParam==(LPARAM)(-2) && nm->iSubItem-3==(nm->nmcd.hdr.idFrom==IDC_PHONES)) hIcon = LoadSkinIcon( SKINICON_OTHER_ADDCONTACT ); else if(nm->iSubItem>1 && nm->nmcd.lItemlParam!=(LPARAM)(-1) && nm->nmcd.lItemlParam!=(LPARAM)(-2)) { static int iconResources[3]={SKINICON_OTHER_RENAME,SKINICON_OTHER_DELETE}; if(nm->iSubItem==2 && nm->nmcd.hdr.idFrom==IDC_PHONES) { TCHAR szText[2]; ListView_GetItemText(nm->nmcd.hdr.hwndFrom,nm->nmcd.dwItemSpec,nm->iSubItem,szText,SIZEOF(szText)); if(szText[0]) hIcon = LoadSkinIcon( SKINICON_OTHER_SMS ); } else hIcon = LoadSkinIcon( iconResources[nm->iSubItem-3+(nm->nmcd.hdr.idFrom==IDC_EMAILS)] ); } else break; DrawIconEx(nm->nmcd.hdc,(rc.left+rc.right-GetSystemMetrics(SM_CXSMICON))/2,(rc.top+rc.bottom-GetSystemMetrics(SM_CYSMICON))/2,hIcon,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL); IconLib_ReleaseIcon(hIcon, 0); SetWindowLongPtr(hwndDlg,DWLP_MSGRESULT,CDRF_SKIPDEFAULT); return TRUE; } } break; } case NM_CLICK: { NMLISTVIEW *nm=(NMLISTVIEW*)lParam; LVITEM lvi; TCHAR szEmail[256]; HANDLE hContact=(HANDLE)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); char *szIdTemplate=nm->hdr.idFrom==IDC_PHONES?"MyPhone%d":"Mye-mail%d"; LVHITTESTINFO hti; if(IsOverEmail(hwndDlg,szEmail,SIZEOF(szEmail))) { TCHAR szExec[264]; mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); ShellExecute(hwndDlg,_T("open"),szExec,NULL,NULL,SW_SHOW); break; } if(nm->iSubItem<2) break; hti.pt.x=(short)LOWORD(GetMessagePos()); hti.pt.y=(short)HIWORD(GetMessagePos()); ScreenToClient(nm->hdr.hwndFrom,&hti.pt); if(ListView_SubItemHitTest(nm->hdr.hwndFrom,&hti)==-1) break; lvi.mask=LVIF_PARAM; lvi.iItem=hti.iItem; lvi.iSubItem=0; ListView_GetItem(nm->hdr.hwndFrom,&lvi); if(lvi.lParam==(LPARAM)(-1)) break; if(lvi.lParam==(LPARAM)(-2)) { if(hti.iSubItem-3==(nm->hdr.idFrom==IDC_PHONES)) { //add char szNewData[256]="",idstr[33]; int i; DBVARIANT dbv; if(IDOK!=DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(nm->hdr.idFrom==IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL),hwndDlg,nm->hdr.idFrom==IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc,(LPARAM)szNewData)) break; for(i=0;;i++) { mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate,i); if(DBGetContactSettingString(hContact,"UserInfo",idstr,&dbv)) break; DBFreeVariant(&dbv); } DBWriteContactSettingString(hContact,"UserInfo",idstr,szNewData); SendMessage(hwndDlg,M_REMAKELISTS,0,0); } } else { if(hti.iSubItem-3==(nm->hdr.idFrom==IDC_PHONES)) { //delete int i; char idstr[33]; DBVARIANT dbv; for(i=lvi.lParam;;i++) { mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate,i+1); if(DBGetContactSettingString(hContact,"UserInfo",idstr,&dbv)) break; mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate,i); DBWriteContactSettingString(hContact,"UserInfo",idstr,dbv.pszVal); DBFreeVariant(&dbv); } mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate,i); DBDeleteContactSetting(hContact,"UserInfo",idstr); SendMessage(hwndDlg,M_REMAKELISTS,0,0); } else if(hti.iSubItem-2==(nm->hdr.idFrom==IDC_PHONES)) { //edit char szText[256],idstr[33]; DBVARIANT dbv; mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate,lvi.lParam); if(DBGetContactSettingString(hContact,"UserInfo",idstr,&dbv)) break; lstrcpynA(szText,dbv.pszVal,SIZEOF(szText)); DBFreeVariant(&dbv); if(IDOK!=DialogBoxParam(hMirandaInst,MAKEINTRESOURCE(nm->hdr.idFrom==IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL),hwndDlg,nm->hdr.idFrom==IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc,(LPARAM)szText)) break; DBWriteContactSettingString(hContact,"UserInfo",idstr,szText); SendMessage(hwndDlg,M_REMAKELISTS,0,0); } } break; } } break; } break; case WM_SETCURSOR: if(LOWORD(lParam)!=HTCLIENT) break; if(GetForegroundWindow()==GetParent(hwndDlg)) { POINT pt; GetCursorPos(&pt); ScreenToClient(hwndDlg,&pt); // SetFocus(ChildWindowFromPoint(hwndDlg,pt)); //ugly hack because listviews ignore their first click } if(IsOverEmail(hwndDlg,NULL,0)) { SetCursor(hHandCursor); SetWindowLongPtr(hwndDlg,DWLP_MSGRESULT,TRUE); return TRUE; } break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: SendMessage(GetParent(hwndDlg),msg,wParam,lParam); break; } break; } return FALSE; }
int Parser() { static NETLIBPACKETRECVER nlpr = {0}; char *ptr; char tmp[256]; int i; char *buf; static char ver[16]; nlpr.cbSize = sizeof(nlpr); nlpr.dwTimeout = 5; if(!ghConnection) { mir_forkthread(&Start, 0); } if(ghConnection) { int recvResult; /* do { recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); if(recvResult == SOCKET_ERROR) { ReStart(); return 1; } } while(recvResult > 0);*/ if(!Connected) { char tmp[128]; char *tmp2 = mir_t2a(gbPassword); recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); if(recvResult == SOCKET_ERROR) { mir_forkthread(&ReStart, 0); // ReStart(); return 1; } if(mir_strlen(tmp2) > 2) { mir_strcpy(tmp, "password "); mir_strcat(tmp, tmp2); mir_strcat(tmp, "\n"); Netlib_Send(ghConnection, tmp, (int)mir_strlen(tmp), 0); recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); if(recvResult == SOCKET_ERROR) { mir_forkthread(&ReStart, 0); return 1; } } mir_free(tmp2); } Netlib_Send(ghConnection, "status\n", (int)mir_strlen("status\n"), 0); recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); if(recvResult == SOCKET_ERROR) { mir_forkthread(&ReStart, 0); return 1; } Netlib_Send(ghConnection, "currentsong\n", (int)mir_strlen("currentsong\n"), 0); recvResult = CallService(MS_NETLIB_GETMOREPACKETS,(WPARAM)ghPacketReciever, (LPARAM)&nlpr); if(recvResult == SOCKET_ERROR) { mir_forkthread(&ReStart, 0); return 1; } nlpr.bytesUsed = nlpr.bytesAvailable; } buf = (char*)nlpr.buffer; if(ptr = strstr(buf, "MPD")) { Connected = TRUE; ptr = &ptr[4]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; strncpy_s(ver, tmp, _TRUNCATE); SongInfo.txtver = mir_utf8decodeT(tmp); } else SongInfo.txtver = mir_utf8decodeT(ver); if(ptr = strstr(buf, "file:")) { ptr = &ptr[6]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.mfile = mir_utf8decodeT(tmp); } else SongInfo.mfile = mir_tstrdup(_T("")); if(ptr = strstr(buf, "Time:")) { ptr = &ptr[6]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.total = atoi(tmp); } else if(!SongInfo.total) SongInfo.total = 0; if(ptr = strstr(buf, "time:")) { ptr = &ptr[6]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.time = atoi(tmp); } else if(!SongInfo.time) SongInfo.time = 0; if(ptr = strstr(buf, "Title:")) { ptr = &ptr[7]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.title = mir_utf8decodeT(tmp); } else SongInfo.title = mir_tstrdup(_T("Unknown track")); if(ptr = strstr(buf, "Artist:")) { ptr = &ptr[8]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.artist = mir_utf8decodeT(tmp); } else SongInfo.artist = mir_tstrdup(_T("Unknown artist")); if(ptr = strstr(buf, "Genre:")) { ptr = &ptr[7]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.genre = mir_utf8decodeT(tmp); } else SongInfo.genre = mir_tstrdup(_T("Unknown genre")); if(ptr = strstr(buf, "Album:")) { ptr = &ptr[7]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.album = mir_utf8decodeT(tmp); } else SongInfo.album = mir_tstrdup(_T("Unknown album")); if(ptr = strstr(buf, "Date:")) { ptr = &ptr[6]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.year = mir_utf8decodeT(tmp); } else SongInfo.year = mir_tstrdup(_T("Unknown year")); if(ptr = strstr(buf, "volume:")) { ptr = &ptr[8]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.volume = atoi(tmp); } else if(!SongInfo.volume) SongInfo.volume = 0; if(ptr = strstr(buf, "audio:")) { ptr = &ptr[7]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.khz = atoi(tmp); } else if(!SongInfo.khz) SongInfo.khz = 0; if(ptr = strstr(buf, "bitrate:")) { ptr = &ptr[9]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.kbps = atoi(tmp); } else if(!SongInfo.kbps) SongInfo.kbps = 0; if(ptr = strstr(buf, "Track:")) { ptr = &ptr[7]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; SongInfo.track = atoi(tmp); } else if(!SongInfo.track) SongInfo.track = 0; if(ptr = strstr(buf, "state:")) { ptr = &ptr[7]; for(i = 0; ((ptr[i] != '\n') && (ptr[i] != '\0')); i++) tmp[i] = ptr[i]; tmp[i] = '\0'; if(strstr(tmp, "play")) gbState = WAT_PLS_PLAYING; if(strstr(tmp, "pause")) gbState = WAT_PLS_PAUSED; if(strstr(tmp, "stop")) gbState = WAT_PLS_STOPPED; } else if(!gbState) gbState = WAT_PLS_UNKNOWN; return 0; }
void CSametimeProto::DeinitConferenceMenu() { debugLog(_T("CSametimeProto::DeinitConferenceMenu()")); CallService(MO_REMOVEMENUITEM, (WPARAM)hLeaveChatMenuItem, 0); CallService(MO_REMOVEMENUITEM, (WPARAM)hCreateChatMenuItem, 0); }
void YmsgrLinksUninit(void) { DestroyServiceFunction(hServiceParseLink); CallService(MS_ASSOCMGR_REMOVEURLTYPE, 0, (LPARAM)"ymsgr:"); }
INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { FileDlgData *dat = (FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { TCHAR szPath[450]; CLISTEVENT* cle = (CLISTEVENT*)lParam; dat = (FileDlgData*)mir_calloc(sizeof(FileDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = cle->hContact; dat->hDbEvent = cle->hDbEvent; dat->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN); dat->dwTicks = GetTickCount(); EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE); Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View user's history")); Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User menu")); TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_FROM, contactName); GetContactReceivedFilesDir(dat->hContact, szPath, SIZEOF(szPath), TRUE); SetDlgItemText(hwndDlg, IDC_FILEDIR, szPath); SHAutoComplete(GetWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), GW_CHILD), 1); for (int i = 0; i < MAX_MRU_DIRS; i++) { char idstr[32]; mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i); DBVARIANT dbv; if (db_get_ts(NULL, "SRFile", idstr, &dbv)) break; SendDlgItemMessage(hwndDlg, IDC_FILEDIR, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal); db_free(&dbv); } db_event_markRead(dat->hContact, dat->hDbEvent); DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent); if (dbei.cbBlob > 4 && dbei.cbBlob <= 8196) { dbei.pBlob = (PBYTE)alloca(dbei.cbBlob + 1); db_event_get(dat->hDbEvent, &dbei); dbei.pBlob[dbei.cbBlob] = 0; dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob; char *str = (char*)dbei.pBlob + 4; ptrT ptszFileName(DbGetEventStringT(&dbei, str)); SetDlgItemText(hwndDlg, IDC_FILENAMES, ptszFileName); unsigned len = (unsigned)strlen(str) + 1; if (len + 4 < dbei.cbBlob) { str += len; ptrT ptszDescription(DbGetEventStringT(&dbei, str)); SetDlgItemText(hwndDlg, IDC_MSG, ptszDescription); } } else DestroyWindow(hwndDlg); TCHAR datetimestr[64]; tmi.printTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, SIZEOF(datetimestr), 0); SetDlgItemText(hwndDlg, IDC_DATE, datetimestr); char* szProto = GetContactProto(dat->hContact); if (szProto) { int hasName = 0; char buf[128]; CONTACTINFO ci = { 0 }; ci.cbSize = sizeof(ci); ci.hContact = dat->hContact; ci.szProto = szProto; ci.dwFlag = CNF_UNIQUEID; if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { switch (ci.type) { case CNFT_ASCIIZ: hasName = 1; mir_snprintf(buf, SIZEOF(buf), "%s", ci.pszVal); mir_free(ci.pszVal); break; case CNFT_DWORD: hasName = 1; mir_snprintf(buf, SIZEOF(buf), "%u", ci.dVal); break; } } if (hasName) SetDlgItemTextA(hwndDlg, IDC_NAME, buf); else SetDlgItemText(hwndDlg, IDC_NAME, contactName); } if (db_get_b(dat->hContact, "CList", "NotOnList", 0)) { RECT rcBtn1, rcBtn2, rcDateCtrl; GetWindowRect(GetDlgItem(hwndDlg, IDC_ADD), &rcBtn1); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rcBtn2); GetWindowRect(GetDlgItem(hwndDlg, IDC_DATE), &rcDateCtrl); SetWindowPos(GetDlgItem(hwndDlg, IDC_DATE), 0, 0, 0, rcDateCtrl.right - rcDateCtrl.left - (rcBtn2.left - rcBtn1.left), rcDateCtrl.bottom - rcDateCtrl.top, SWP_NOZORDER | SWP_NOMOVE); } else if (db_get_b(NULL, "SRFile", "AutoAccept", 0)) { //don't check auto-min here to fix BUG#647620 PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK)); } if (!db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } return TRUE; case WM_MEASUREITEM: return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto = GetContactProto(dat->hContact); if (szProto) { HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); if (hIcon) { DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); } } } } return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case WM_COMMAND: if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { case IDC_FILEDIRBROWSE: { TCHAR szDirName[MAX_PATH], szExistingDirName[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, szDirName, SIZEOF(szDirName)); GetLowestExistingDirName(szDirName, szExistingDirName, SIZEOF(szExistingDirName)); if (BrowseForFolder(hwndDlg, szExistingDirName)) SetDlgItemText(hwndDlg, IDC_FILEDIR, szExistingDirName); } break; case IDOK: { //most recently used directories TCHAR szRecvDir[MAX_PATH], szDefaultRecvDir[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILEDIR, szRecvDir, SIZEOF(szRecvDir)); RemoveInvalidPathChars(szRecvDir); GetContactReceivedFilesDir(NULL, szDefaultRecvDir, SIZEOF(szDefaultRecvDir), TRUE); if (_tcsnicmp(szRecvDir, szDefaultRecvDir, lstrlen(szDefaultRecvDir))) { char idstr[32]; int i; DBVARIANT dbv; for (i = MAX_MRU_DIRS-2;i>=0;i--) { mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i); if (db_get_ts(NULL, "SRFile", idstr, &dbv)) continue; mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i+1); db_set_ts(NULL, "SRFile", idstr, dbv.ptszVal); db_free(&dbv); } db_set_ts(NULL, "SRFile", idstr, szRecvDir); } } EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAMES), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIR), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILEDIRBROWSE), FALSE); GetDlgItemText(hwndDlg, IDC_FILEDIR, dat->szSavePath, SIZEOF(dat->szSavePath)); GetDlgItemText(hwndDlg, IDC_FILE, dat->szFilenames, SIZEOF(dat->szFilenames)); GetDlgItemText(hwndDlg, IDC_MSG, dat->szMsg, SIZEOF(dat->szMsg)); dat->hwndTransfer = FtMgr_AddTransfer(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); //check for auto-minimize here to fix BUG#647620 if (db_get_b(NULL, "SRFile", "AutoAccept", 0) && db_get_b(NULL, "SRFile", "AutoMin", 0)) { ShowWindow(hwndDlg, SW_HIDE); ShowWindow(hwndDlg, SW_SHOWMINNOACTIVE); } DestroyWindow(hwndDlg); break; case IDCANCEL: if (dat->fs) CallContactService(dat->hContact, PSS_FILEDENYT, (WPARAM)dat->fs, (LPARAM)TranslateT("Canceled")); dat->fs = NULL; /* the protocol will free the handle */ DestroyWindow(hwndDlg); break; case IDC_ADD: { ADDCONTACTSTRUCT acs = { 0 }; acs.hContact = dat->hContact; acs.handleType = HANDLE_CONTACT; acs.szProto = ""; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); if (!db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); } break; case IDC_USERMENU: { RECT rc; HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect((HWND)lParam, &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); break; } break; case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); if (dat) FreeFileDlgData(dat); break; } return FALSE; }
struct CListEvent* AddEvent(CLISTEVENT *cle) { struct CListEvent* p = saveAddEvent(cle); if ( p == NULL ) return NULL; if (1) { if (p->cle.hContact != 0 && p->cle.hDbEvent != (HANDLE) 1 && !(p->cle.flags & CLEF_ONLYAFEW)) { int j; struct NotifyMenuItemExData *nmi = 0; char *szProto; TCHAR *szName; MENUITEMINFO mii = {0}; mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA | MIIM_BITMAP | MIIM_ID; if (p->cle.pszService && !strncmp("SRMsg/ReadMessage", p->cle.pszService, 17)) { // dup check only for msg events for (j = 0; j < GetMenuItemCount(cfg::dat.hMenuNotify); j++) { if (GetMenuItemInfo(cfg::dat.hMenuNotify, j, TRUE, &mii) != 0) { nmi = (struct NotifyMenuItemExData *) mii.dwItemData; if (nmi != 0 && (HANDLE) nmi->hContact == (HANDLE) p->cle.hContact && nmi->iIcon == p->imlIconIndex) return p; } } } szProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) p->cle.hContact, 0); szName = pcli->pfnGetContactDisplayName(p->cle.hContact, 0); if (szProto && szName) { nmi = (struct NotifyMenuItemExData *) malloc(sizeof(struct NotifyMenuItemExData)); if (nmi) { TCHAR szBuffer[128]; TCHAR* szStatus = pcli->pfnGetStatusModeDescription(cfg::getWord(p->cle.hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); #if defined(_UNICODE) TCHAR szwProto[64]; MultiByteToWideChar(CP_ACP, 0, szProto, -1, szwProto, 64); szwProto[63] = 0; _snwprintf(szBuffer, SIZEOF(szBuffer), L"%s: %s (%s)", szwProto, szName, szStatus); #else _snprintf(szBuffer, SIZEOF(szBuffer), "%s: %s (%s)", szProto, szName, szStatus); #endif szBuffer[127] = 0; AppendMenu(cfg::dat.hMenuNotify, MF_BYCOMMAND | MF_STRING, cfg::dat.wNextMenuID, szBuffer); mii.hbmpItem = HBMMENU_CALLBACK; nmi->hContact = p->cle.hContact; nmi->iIcon = p->imlIconIndex; nmi->hIcon = p->cle.hIcon; nmi->hDbEvent = p->cle.hDbEvent; mii.dwItemData = (ULONG_PTR) nmi; mii.wID = cfg::dat.wNextMenuID; SetMenuItemInfo(cfg::dat.hMenuNotify, cfg::dat.wNextMenuID, FALSE, &mii); p-> menuId = cfg::dat.wNextMenuID; cfg::dat.wNextMenuID++; if (cfg::dat.wNextMenuID > 0x7fff) cfg::dat.wNextMenuID = 1; cfg::dat.hIconNotify = p->imlIconIndex; } } } else if (p->cle.hContact != 0 && (p->cle.flags & CLEF_ONLYAFEW)) { cfg::dat.hIconNotify = p->imlIconIndex; cfg::dat.hUpdateContact = p->cle.hContact; } if (cfg::dat.dwFlags & CLUI_STICKYEVENTS) { HANDLE hItem = (HANDLE) SendMessage(pcli->hwndContactTree, CLM_FINDCONTACT, (WPARAM) p->cle.hContact, 0); if (hItem) { SendMessage(pcli->hwndContactTree, CLM_SETSTICKY, (WPARAM) hItem, 1); pcli->pfnClcBroadcast(INTM_PROTOCHANGED, (WPARAM) p->cle.hContact, 0); } } if (pcli->events.count > 0) { cfg::dat.bEventAreaEnabled = TRUE; if (cfg::dat.notifyActive == 0) { cfg::dat.notifyActive = 1; HideShowNotifyFrame(); } } InvalidateRect(hwndEventFrame, NULL, FALSE); if(cfg::dat.bUseFloater & CLUI_USE_FLOATER && cfg::dat.bUseFloater & CLUI_FLOATER_EVENTS) SFL_Update(0, 0, 0, NULL, FALSE); } return p; }
LRESULT CALLBACK EventAreaWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CREATE: hwndEventFrame = hwnd; return FALSE; case WM_MEASUREITEM: { MEASUREITEMSTRUCT *lpi = (LPMEASUREITEMSTRUCT) lParam; MENUITEMINFOA mii = {0}; mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA | MIIM_ID; if (GetMenuItemInfoA(cfg::dat.hMenuNotify, lpi->itemID, FALSE, &mii) != 0) { if (mii.dwItemData == lpi->itemData) { lpi->itemWidth = 8 + 16; lpi->itemHeight = 0; return TRUE; } } break; } case WM_NCCALCSIZE: return FrameNCCalcSize(hwnd, DefWindowProc, wParam, lParam, wndFrameEventArea ? wndFrameEventArea->TitleBar.ShowTitleBar : 0); case WM_NCPAINT: return FrameNCPaint(hwnd, DefWindowProc, wParam, lParam, wndFrameEventArea ? wndFrameEventArea->TitleBar.ShowTitleBar : 0); case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam; if (dis->hwndItem == (HWND) cfg::dat.hMenuNotify) { MENUITEMINFOA mii = {0}; struct NotifyMenuItemExData *nmi = 0; int iIcon; HICON hIcon; mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA; if (GetMenuItemInfoA(cfg::dat.hMenuNotify, (UINT) dis->itemID, FALSE, &mii) != 0) { nmi = (struct NotifyMenuItemExData *) mii.dwItemData; if (nmi) { iIcon = CallService(MS_CLIST_GETCONTACTICON, (WPARAM) nmi->hContact, 0); hIcon = ImageList_GetIcon(hCListImages, iIcon, ILD_NORMAL); pcli->pfnDrawMenuItem(dis, hIcon, nmi->hIcon); return TRUE; } } } break; } case WM_LBUTTONUP: if(cfg::dat.bEventAreaEnabled) SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_NOTIFYBUTTON, 0), 0); break; case WM_COMMAND: if(LOWORD(wParam) == IDC_NOTIFYBUTTON) { int iSelection; MENUITEMINFO mii = {0}; POINT pt; struct NotifyMenuItemExData *nmi = 0; int iCount = GetMenuItemCount(cfg::dat.hMenuNotify); BOOL result; GetCursorPos(&pt); mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA; if (iCount > 1) iSelection = TrackPopupMenu(cfg::dat.hMenuNotify, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL); else iSelection = GetMenuItemID(cfg::dat.hMenuNotify, 0); result = GetMenuItemInfo(cfg::dat.hMenuNotify, (UINT) iSelection, FALSE, &mii); if (result != 0) { nmi = (struct NotifyMenuItemExData *) mii.dwItemData; if (nmi) { CLISTEVENT *cle = MyGetEvent(iSelection); if (cle) { CLISTEVENT *cle1 = NULL; CallService(cle->pszService, (WPARAM) NULL, (LPARAM) cle); // re-obtain the pointer, it may already be invalid/point to another event if the // event we're interested in was removed by the service (nasty one...) cle1 = MyGetEvent(iSelection); if (cle1 != NULL) CallService(MS_CLIST_REMOVEEVENT, (WPARAM) cle->hContact, (LPARAM) cle->hDbEvent); } } } break; } break; case WM_ERASEBKGND: return TRUE; case WM_PAINT: { PAINTSTRUCT ps; RECT rc, rcClient; HDC hdc = BeginPaint(hwnd, &ps); LONG dwLeft; HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hbm, hbmold; StatusItems_t *item; int height; HFONT hFontOld = 0; GetClientRect(hwnd, &rc); rcClient = rc; hbm = CreateCompatibleBitmap(hdc, rc.right, rc.bottom); hbmold = reinterpret_cast<HBITMAP>(SelectObject(hdcMem, hbm)); SetBkMode(hdcMem, TRANSPARENT); if(cfg::clcdat) hFontOld = ChangeToFont(hdcMem, cfg::clcdat, FONTID_EVENTAREA, &height); if(cfg::dat.bWallpaperMode) SkinDrawBg(hwnd, hdcMem); item = &StatusItems[ID_EXTBKEVTAREA - ID_STATUS_OFFLINE]; if(item->IGNORED) { FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE)); } else { rc.top += item->MARGIN_TOP; rc.bottom -= item->MARGIN_BOTTOM; rc.left += item->MARGIN_LEFT; rc.right -= item->MARGIN_RIGHT; DrawAlpha(hdcMem, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT, item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem); SetTextColor(hdcMem, item->TEXTCOLOR); } dwLeft = rc.left; PaintNotifyArea(hdcMem, &rc); if(cfg::dat.dwFlags & CLUI_FRAME_EVENTAREASUNKEN) { rc.left = dwLeft; InflateRect(&rc, -2, -2); DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT); } BitBlt(hdc, 0, 0, rcClient.right, rcClient.bottom, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmold); if(hFontOld) SelectObject(hdcMem, hFontOld); DeleteObject(hbm); DeleteDC(hdcMem); ps.fErase = FALSE; EndPaint(hwnd, &ps); return 0; } default: return DefWindowProc(hwnd, msg, wParam, lParam); } return TRUE; }
INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static int iState = 0; switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { TCHAR filename[MAX_PATH], *productCopyright; DWORD unused; DWORD verInfoSize; UINT blockSize; PVOID pVerInfo; GetModuleFileName(NULL,filename,SIZEOF(filename)); verInfoSize=GetFileVersionInfoSize(filename,&unused); pVerInfo=mir_alloc(verInfoSize); GetFileVersionInfo(filename,0,verInfoSize,pVerInfo); VerQueryValue(pVerInfo,_T("\\StringFileInfo\\000004b0\\LegalCopyright"),(LPVOID*)&productCopyright,&blockSize); SetDlgItemText(hwndDlg,IDC_DEVS,productCopyright); mir_free(pVerInfo); } { char productVersion[56], *p; int isAnsi = 0; TCHAR str[64]; CallService(MS_SYSTEM_GETVERSIONTEXT,SIZEOF(productVersion),(LPARAM)productVersion); // Hide Unicode from version text as it is assumed at this point p = strstr(productVersion, " Unicode"); if (p) *p = '\0'; else isAnsi = 1; mir_sntprintf(str,SIZEOF(str),_T(STR_VERSION_FORMAT), TranslateT("v"), productVersion, isAnsi?" ANSI":""); { TCHAR oldTitle[256], newTitle[256]; GetDlgItemText( hwndDlg, IDC_HEADERBAR, oldTitle, SIZEOF( oldTitle )); mir_sntprintf( newTitle, SIZEOF(newTitle), oldTitle, str ); SetDlgItemText( hwndDlg, IDC_HEADERBAR, newTitle ); } mir_sntprintf(str,SIZEOF(str),TranslateT("Built %s %s"),_T(__DATE__),_T(__TIME__)); SetDlgItemText(hwndDlg,IDC_BUILDTIME,str); } ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); { HRSRC hResInfo = FindResource(hMirandaInst,MAKEINTRESOURCE(IDR_CREDITS),_T("TEXT")); DWORD ResSize = SizeofResource(hMirandaInst,hResInfo); HGLOBAL hRes = LoadResource(hMirandaInst,hResInfo); char* pszMsg = (char*)LockResource(hRes); if (pszMsg) { char* pszMsgt = (char*)alloca(ResSize + 1); memcpy(pszMsgt, pszMsg, ResSize); pszMsgt[ResSize] = 0; TCHAR *ptszMsg; if (ResSize >=3 && pszMsgt[0] == '\xef' && pszMsgt[1] == '\xbb' && pszMsgt[2] == '\xbf') ptszMsg = Utf8DecodeT(pszMsgt + 3); else ptszMsg = mir_a2t_cp(pszMsgt, 1252); SetDlgItemText(hwndDlg, IDC_CREDITSFILE, ptszMsg); UnlockResource(pszMsg); mir_free(ptszMsg); } FreeResource(hRes); } Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_MIRANDA); return TRUE; case WM_COMMAND: switch( LOWORD( wParam )) { case IDOK: case IDCANCEL: DestroyWindow(hwndDlg); return TRUE; case IDC_CONTRIBLINK: if (iState) { iState = 0; SetDlgItemText(hwndDlg, IDC_CONTRIBLINK, TranslateT("Credits >")); ShowWindow(GetDlgItem(hwndDlg, IDC_DEVS), SW_SHOW); ShowWindow(GetDlgItem(hwndDlg, IDC_BUILDTIME), SW_SHOW); ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); } else { iState = 1; SetDlgItemText(hwndDlg, IDC_CONTRIBLINK, TranslateT("< Copyright")); ShowWindow(GetDlgItem(hwndDlg, IDC_DEVS), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_BUILDTIME), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_SHOW); } break; } break; case WM_CTLCOLOREDIT: case WM_CTLCOLORSTATIC: switch ( GetWindowLongPtr(( HWND )lParam, GWL_ID )) { case IDC_WHITERECT: case IDC_BUILDTIME: case IDC_CREDITSFILE: case IDC_DEVS: SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); break; default: return FALSE; } SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); case WM_DESTROY: Window_FreeIcon_IcoLib( hwndDlg ); { HFONT hFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_VERSION,WM_GETFONT,0,0); SendDlgItemMessage(hwndDlg,IDC_VERSION,WM_SETFONT,SendDlgItemMessage(hwndDlg,IDOK,WM_GETFONT,0,0),0); DeleteObject(hFont); } break; } return FALSE; }
LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { TVITEM tvi; CCList *dat = CWndUserData(GetParent(hWnd)).GetCList(); switch (Msg) { case INTM_CONTACTDELETED: // wParam = (HANDLE)hContact { HTREEITEM hItem = dat->FindContact(wParam); if (hItem) TreeView_DeleteItem(hWnd, hItem); } break; case INTM_ICONCHANGED: // wParam = (HANDLE)hContact, lParam = IconID tvi.hItem = dat->FindContact(wParam); if (tvi.hItem) { tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvi.iImage = tvi.iSelectedImage = lParam; TreeView_SetItem(hWnd, &tvi); dat->SortContacts(); InvalidateRect(hWnd, NULL, false); } break; case INTM_INVALIDATE: InvalidateRect(hWnd, NULL, true); break; case WM_RBUTTONDOWN: SetFocus(hWnd); { TVHITTESTINFO hitTest; hitTest.pt.x = (short)LOWORD(lParam); hitTest.pt.y = (short)HIWORD(lParam); TreeView_HitTest(hWnd, &hitTest); if (hitTest.hItem && hitTest.flags & TVHT_ONITEM) TreeView_SelectItem(hWnd, hitTest.hItem); } return DefWindowProc(hWnd, Msg, wParam, lParam); case WM_LBUTTONDOWN: { POINT pt = { (short)LOWORD(lParam), (short)HIWORD(lParam) }; DWORD hitFlags; HTREEITEM hItem = dat->HitTest(&pt, &hitFlags); if (!hItem) break; if (hitFlags & MCLCHT_ONITEMICON) { if (TreeView_GetChild(hWnd, hItem)) { // if it's a group, then toggle its state NMTREEVIEW nmtv; nmtv.hdr.hwndFrom = hWnd; nmtv.hdr.idFrom = GetDlgCtrlID(hWnd); nmtv.hdr.code = TVN_ITEMEXPANDING; nmtv.action = TVE_TOGGLE; nmtv.itemNew.hItem = hItem; nmtv.itemNew.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; TreeView_GetItem(hWnd, &nmtv.itemNew); nmtv.ptDrag = pt; if (SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nmtv)) return 0; HTREEITEM hOldSelItem = TreeView_GetSelection(hWnd); TreeView_Expand(hWnd, hItem, TVE_TOGGLE); HTREEITEM hNewSelItem = TreeView_GetSelection(hWnd); if (hNewSelItem != hOldSelItem) { TreeView_SetItemState(hWnd, hOldSelItem, (dat->SelectedItems.Find(hOldSelItem) == -1) ? 0 : TVIS_SELECTED, TVIS_SELECTED); TreeView_SetItemState(hWnd, hNewSelItem, (dat->SelectedItems.Find(hNewSelItem) == -1) ? 0 : TVIS_SELECTED, TVIS_SELECTED); } nmtv.hdr.code = TVN_ITEMEXPANDED; TreeView_GetItem(hWnd, &nmtv.itemNew); SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nmtv); return 0; } } if (hitFlags & MCLCHT_ONITEM) { if (wParam & MK_CONTROL) { SetFocus(hWnd); TREEITEMARRAY OldSelection = dat->SelectedItems; int nIndex = dat->SelectedItems.Find(hItem); if (nIndex == -1) { TreeView_SetItemState(hWnd, hItem, TVIS_SELECTED, TVIS_SELECTED); dat->SelectedItems.AddElem(hItem); } else { TreeView_SetItemState(hWnd, hItem, 0, TVIS_SELECTED); dat->SelectedItems.RemoveElem(nIndex); } dat->SelectGroups(hItem, nIndex == -1); NMCLIST nm; nm.hdr.code = MCLN_SELCHANGED; nm.hdr.hwndFrom = hWnd; nm.hdr.idFrom = GetDlgCtrlID(hWnd); nm.OldSelection = &OldSelection; nm.NewSelection = &dat->SelectedItems; SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nm); return 0; } // if it was a click on the selected item and there's need to do something in this case, then send SELCHANGED notification by ourselves, as the tree control doesn't do anything if (hItem == TreeView_GetSelection(hWnd) && (dat->SelectedItems.GetSize() != 1 || (dat->SelectedItems.GetSize() == 1 && dat->SelectedItems[0] != hItem))) { TreeView_SetItemState(hWnd, hItem, TVIS_SELECTED, TVIS_SELECTED); NMTREEVIEW nm = { 0 }; nm.hdr.code = TVN_SELCHANGED; nm.hdr.hwndFrom = hWnd; nm.hdr.idFrom = GetDlgCtrlID(hWnd); nm.itemOld.hItem = TreeView_GetSelection(hWnd); nm.itemOld.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM; TreeView_GetItem(hWnd, &nm.itemOld); nm.itemNew = nm.itemOld; SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nm); } } } break; case WM_SETFOCUS: case WM_KILLFOCUS: for (int i = 0; i < dat->SelectedItems.GetSize(); i++) { RECT rc; if (TreeView_GetItemRect(hWnd, dat->SelectedItems[i], &rc, false)) InvalidateRect(hWnd, &rc, false); } break; case WM_SIZE: case WM_HSCROLL: InvalidateRect(hWnd, NULL, false); break; case WM_MEASUREITEM: if (!wParam) // if the message was sent by a menu return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam); break; case WM_DRAWITEM: if (!wParam) // if the message was sent by a menu return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); break; case WM_CONTEXTMENU: { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; HTREEITEM hItem = NULL; if (pt.x == -1 && pt.y == -1) { if (dat->SelectedItems.GetSize() == 1) { hItem = dat->SelectedItems[0]; TreeView_EnsureVisible(hWnd, hItem); RECT rc; TreeView_GetItemRect(hWnd, hItem, &rc, true); pt.x = rc.left; pt.y = rc.bottom; } } else { DWORD hitFlags; ScreenToClient(hWnd, &pt); hItem = dat->HitTest(&pt, &hitFlags); if (!(hitFlags & MCLCHT_ONITEM)) hItem = NULL; } if (hItem) { MCONTACT hContact = dat->GetItemData(hItem).hContact; if (IsHContactContact(hContact)) { HMENU hMenu = Menu_BuildContactMenu(hContact); if (hMenu) { ClientToScreen(hWnd, &pt); CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hWnd, NULL), MPCF_CONTACTMENU), hContact); DestroyMenu(hMenu); return 0; } } } } break; case WM_DESTROY: if (dat->ExtraImageList) ImageList_Destroy(dat->ExtraImageList); dat->SelectedItems.RemoveAll(); dat->Items.RemoveAll(); break; } return CallWindowProc(dat->OrigTreeViewProc, hWnd, Msg, wParam, lParam); }
INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { MEVENT hDbEvent = (MEVENT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); hDbEvent = lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); { //blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(hDbEvent); dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); db_event_get(hDbEvent, &dbei); DWORD uin = *(PDWORD)dbei.pBlob; MCONTACT hContact = DbGetAuthEventContact(&dbei); char* nick = (char*)dbei.pBlob + sizeof(DWORD) * 2; char* first = nick + mir_strlen(nick) + 1; char* last = first + mir_strlen(first) + 1; char* email = last + mir_strlen(last) + 1; SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0)); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0)); PROTOACCOUNT* acc = Proto_GetAccount(dbei.szModule); TCHAR* lastT = dbei.flags & DBEF_UTF ? Utf8DecodeT(last) : mir_a2t(last); TCHAR* firstT = dbei.flags & DBEF_UTF ? Utf8DecodeT(first) : mir_a2t(first); TCHAR* nickT = dbei.flags & DBEF_UTF ? Utf8DecodeT(nick) : mir_a2t(nick); TCHAR* emailT = dbei.flags & DBEF_UTF ? Utf8DecodeT(email) : mir_a2t(email); TCHAR name[128] = _T(""); int off = 0; if (firstT[0] && lastT[0]) off = mir_sntprintf(name, _T("%s %s"), firstT, lastT); else if (firstT[0]) off = mir_sntprintf(name, _T("%s"), firstT); else if (lastT[0]) off = mir_sntprintf(name, _T("%s"), lastT); if (nickT[0]) { if (off) mir_sntprintf(name + off, _countof(name) - off, _T(" (%s)"), nickT); else _tcsncpy_s(name, nickT, _TRUNCATE); } if (!name[0]) _tcsncpy_s(name, TranslateT("<Unknown>"), _TRUNCATE); TCHAR hdr[256]; if (uin && emailT[0]) mir_sntprintf(hdr, TranslateT("%s added you to the contact list\n%u (%s) on %s"), name, uin, emailT, acc->tszAccountName); else if (uin) mir_sntprintf(hdr, TranslateT("%s added you to the contact list\n%u on %s"), name, uin, acc->tszAccountName); else mir_sntprintf(hdr, TranslateT("%s added you to the contact list\n%s on %s"), name, emailT[0] ? emailT : TranslateT("(Unknown)"), acc->tszAccountName); SetDlgItemText(hwndDlg, IDC_HEADERBAR, hdr); mir_free(lastT); mir_free(firstT); mir_free(nickT); mir_free(emailT); SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA, (LONG_PTR)hContact); if (hContact == INVALID_CONTACT_ID || !db_get_b(hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ADD: { ADDCONTACTSTRUCT acs = { 0 }; acs.hDbEvent = hDbEvent; acs.handleType = HANDLE_EVENT; acs.szProto = ""; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); MCONTACT hContact = (MCONTACT)GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA); if ((hContact == INVALID_CONTACT_ID) || !db_get_b(hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); } break; case IDC_DETAILS: { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA); CallService(MS_USERINFO_SHOWDIALOG, hContact, 0); } break; case IDOK: { ADDCONTACTSTRUCT acs = { 0 }; acs.hDbEvent = hDbEvent; acs.handleType = HANDLE_EVENT; acs.szProto = ""; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); } //fall through case IDCANCEL: DestroyWindow(hwndDlg); break; } break; case WM_DESTROY: Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); break; } return FALSE; }
INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { MEVENT hDbEvent = (MEVENT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View user's details")); Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add contact permanently to list")); { hDbEvent = lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); //blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(hDbEvent); dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); db_event_get(hDbEvent, &dbei); DWORD uin = *(PDWORD)dbei.pBlob; MCONTACT hContact = DbGetAuthEventContact(&dbei); char *nick = (char*)dbei.pBlob + sizeof(DWORD) * 2; char *first = nick + mir_strlen(nick) + 1; char *last = first + mir_strlen(first) + 1; char *email = last + mir_strlen(last) + 1; char *reason = email + mir_strlen(email) + 1; SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0)); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0)); PROTOACCOUNT* acc = Proto_GetAccount(dbei.szModule); ptrT lastT(dbei.flags & DBEF_UTF ? Utf8DecodeT(last) : mir_a2t(last)); ptrT firstT(dbei.flags & DBEF_UTF ? Utf8DecodeT(first) : mir_a2t(first)); ptrT nickT(dbei.flags & DBEF_UTF ? Utf8DecodeT(nick) : mir_a2t(nick)); ptrT emailT(dbei.flags & DBEF_UTF ? Utf8DecodeT(email) : mir_a2t(email)); ptrT reasonT(dbei.flags & DBEF_UTF ? Utf8DecodeT(reason) : mir_a2t(reason)); TCHAR name[128] = _T(""); int off = 0; if (firstT[0] && lastT[0]) off = mir_sntprintf(name, _T("%s %s"), (TCHAR*)firstT, (TCHAR*)lastT); else if (firstT[0]) off = mir_sntprintf(name, _T("%s"), (TCHAR*)firstT); else if (lastT[0]) off = mir_sntprintf(name, _T("%s"), (TCHAR*)lastT); if (mir_tstrlen(nickT)) { if (off) mir_sntprintf(name + off, _countof(name) - off, _T(" (%s)"), (TCHAR*)nickT); else _tcsncpy_s(name, nickT, _TRUNCATE); } if (!name[0]) _tcsncpy_s(name, TranslateT("<Unknown>"), _TRUNCATE); TCHAR hdr[256]; if (uin && emailT[0]) mir_sntprintf(hdr, TranslateT("%s requested authorization\n%u (%s) on %s"), name, uin, (TCHAR*)emailT, acc->tszAccountName); else if (uin) mir_sntprintf(hdr, TranslateT("%s requested authorization\n%u on %s"), name, uin, acc->tszAccountName); else mir_sntprintf(hdr, TranslateT("%s requested authorization\n%s on %s"), name, emailT[0] ? (TCHAR*)emailT : TranslateT("(Unknown)"), acc->tszAccountName); SetDlgItemText(hwndDlg, IDC_HEADERBAR, hdr); SetDlgItemText(hwndDlg, IDC_REASON, reasonT); if (hContact == INVALID_CONTACT_ID || !db_get_b(hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); SendDlgItemMessage(hwndDlg, IDC_DENYREASON, EM_LIMITTEXT, 255, 0); if (CallProtoService(dbei.szModule, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_NOAUTHDENYREASON) { EnableWindow(GetDlgItem(hwndDlg, IDC_DENYREASON), FALSE); SetDlgItemText(hwndDlg, IDC_DENYREASON, TranslateT("Feature is not supported by protocol")); } if (!db_get_b(hContact, "CList", "NotOnList", 0)) { EnableWindow(GetDlgItem(hwndDlg, IDC_ADDCHECK), FALSE); CheckDlgButton(hwndDlg, IDC_ADDCHECK, BST_UNCHECKED); } else CheckDlgButton(hwndDlg, IDC_ADDCHECK, BST_CHECKED); SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_DETAILS), GWLP_USERDATA, (LONG_PTR)hContact); } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, GetWindowLongPtr((HWND)lParam, GWLP_USERDATA), 0); break; case IDC_DECIDELATER: DestroyWindow(hwndDlg); break; case IDOK: { DBEVENTINFO dbei = { sizeof(dbei) }; db_event_get(hDbEvent, &dbei); CallProtoService(dbei.szModule, PS_AUTHALLOW, (WPARAM)hDbEvent, 0); if (IsDlgButtonChecked(hwndDlg, IDC_ADDCHECK)) { ADDCONTACTSTRUCT acs = { 0 }; acs.hDbEvent = hDbEvent; acs.handleType = HANDLE_EVENT; acs.szProto = ""; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); } } DestroyWindow(hwndDlg); break; case IDCANCEL: { DBEVENTINFO dbei = { sizeof(dbei) }; db_event_get(hDbEvent, &dbei); if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_DENYREASON))) { TCHAR tszReason[256]; GetDlgItemText(hwndDlg, IDC_DENYREASON, tszReason, _countof(tszReason)); CallProtoService(dbei.szModule, PS_AUTHDENY, hDbEvent, (LPARAM)tszReason); } else CallProtoService(dbei.szModule, PS_AUTHDENY, hDbEvent, 0); } DestroyWindow(hwndDlg); break; } break; case WM_DESTROY: Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); DestroyIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); break; } return FALSE; }
// CLI_SETUSERINFO void CIcqProto::setUserInfo() { icq_packet packet; size_t wAdditionalData = 0; BYTE bXStatus = getContactXStatus(NULL); if (m_bAimEnabled) wAdditionalData += 16; #ifdef DBG_CAPMTN wAdditionalData += 16; #endif if (m_bUtfEnabled) wAdditionalData += 16; #ifdef DBG_NEWCAPS wAdditionalData += 16; #endif #ifdef DBG_CAPXTRAZ wAdditionalData += 16; #endif #ifdef DBG_OSCARFT wAdditionalData += 16; #endif if (m_bAvatarsEnabled) wAdditionalData += 16; if (m_bXStatusEnabled && bXStatus != 0) wAdditionalData += 16; #ifdef DBG_CAPHTML wAdditionalData += 16; #endif #ifdef DBG_AIMCONTACTSEND wAdditionalData += 16; #endif wAdditionalData += CustomCapList.getCount() * 16; //MIM/PackName bool bHasPackName = false; DBVARIANT dbv; if (!db_get_s(NULL, "ICQCaps", "PackName", &dbv)) { //MIM/PackName bHasPackName = true; wAdditionalData += 16; } serverPacketInit(&packet, 62 + wAdditionalData); packFNACHeader(&packet, ICQ_LOCATION_FAMILY, ICQ_LOCATION_SET_USER_INFO); /* TLV(5): capability data */ packWord(&packet, 0x0005); packWord(&packet, WORD(48 + wAdditionalData)); #ifdef DBG_CAPMTN packDWord(&packet, 0x563FC809); // CAP_TYPING packDWord(&packet, 0x0B6F41BD); packDWord(&packet, 0x9F794226); packDWord(&packet, 0x09DFA2F3); #endif packShortCapability(&packet, 0x1349); // AIM_CAPS_ICQSERVERRELAY // Broadcasts the capability to receive UTF8 encoded messages if (m_bUtfEnabled) packShortCapability(&packet, 0x134E); // CAP_UTF8MSGS #ifdef DBG_NEWCAPS // Tells server we understand to new format of caps packShortCapability(&packet, 0x0000); // CAP_SHORTCAPS #endif #ifdef DBG_CAPXTRAZ packDWord(&packet, 0x1a093c6c); // CAP_XTRAZ packDWord(&packet, 0xd7fd4ec5); // Broadcasts the capability to handle packDWord(&packet, 0x9d51a647); // Xtraz packDWord(&packet, 0x4e34f5a0); #endif if (m_bAvatarsEnabled) packShortCapability(&packet, 0x134C); // CAP_DEVILS #ifdef DBG_OSCARFT // Broadcasts the capability to receive Oscar File Transfers packShortCapability(&packet, 0x1343); // CAP_AIM_FILE #endif // Tells the server we can speak to AIM if (m_bAimEnabled) packShortCapability(&packet, 0x134D); // CAP_AIM_COMPATIBLE #ifdef DBG_AIMCONTACTSEND packShortCapability(&packet, 0x134B); // CAP_SENDBUDDYLIST #endif if (m_bXStatusEnabled && bXStatus != 0) packBuffer(&packet, capXStatus[bXStatus - 1], BINARY_CAP_SIZE); packShortCapability(&packet, 0x1344); // CAP_ICQDIRECT #ifdef DBG_CAPHTML packShortCapability(&packet, 0x0002); // CAP_HTMLMSGS #endif packDWord(&packet, 0x4D697261); // Miranda Signature packDWord(&packet, 0x6E64614E); WORD v[4]; CallService(MS_SYSTEM_GETFILEVERSION, 0, (LPARAM)v); packWord(&packet, v[0]); packWord(&packet, v[1]); packWord(&packet, v[2]); packWord(&packet, v[3]); //MIM/PackName if (bHasPackName) { packBuffer(&packet, (BYTE*)dbv.pszVal, 0x10); db_free(&dbv); } if (CustomCapList.getCount()) for (int i = 0; i < CustomCapList.getCount(); i++) packBuffer(&packet, (PBYTE)CustomCapList[i].caps, 0x10); sendServPacket(&packet); }
int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) { GCHOOK *gch = (GCHOOK *)lParam; GGGC *chat = NULL; uin_t uin; // Check if we got our protocol, and fields are set if (!gch || !gch->pDest || !gch->pDest->ptszID || !gch->pDest->pszModule || lstrcmpiA(gch->pDest->pszModule, m_szModuleName) || !(uin = getDword(GG_KEY_UIN, 0)) || !(chat = gc_lookup(gch->pDest->ptszID))) return 0; // Window terminated (Miranda exit) if (gch->pDest->iType == SESSION_TERMINATE) { debugLog(_T("gc_event(): Terminating chat %x, id %s from chat window..."), chat, gch->pDest->ptszID); // Destroy chat entry free(chat->recipients); list_remove(&chats, chat, 1); // Remove contact from contact list (duh!) should be done by chat.dll !! for (HANDLE hContact = db_find_first(); hContact; ) { HANDLE hNext = db_find_next(hContact); DBVARIANT dbv; if (!getTString(hContact, "ChatRoomID", &dbv)) { if (dbv.ptszVal && !_tcscmp(gch->pDest->ptszID, dbv.ptszVal)) CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0); db_free(&dbv); } hContact = hNext; } return 1; } // Message typed / send only if online if (isonline() && (gch->pDest->iType == GC_USER_MESSAGE) && gch->ptszText) { TCHAR id[32]; UIN2IDT(uin, id); DBVARIANT dbv; GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_MESSAGE }; GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszUID = id; gce.ptszText = gch->ptszText; TCHAR* nickT; if (!getTString(GG_KEY_NICK, &dbv)){ nickT = mir_tstrdup(dbv.ptszVal); db_free(&dbv); } else nickT = mir_tstrdup(TranslateT("Me")); gce.ptszNick = nickT; // Get rid of CRLF at back int lc = (int)_tcslen(gch->ptszText) - 1; while(lc >= 0 && (gch->ptszText[lc] == '\n' || gch->ptszText[lc] == '\r')) gch->ptszText[lc --] = 0; gce.time = time(NULL); gce.bIsMe = 1; gce.dwFlags = GCEF_ADDTOLOG; debugLog(_T("gc_event(): Sending conference message to room %s, \"%s\"."), gch->pDest->ptszID, gch->ptszText); CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); mir_free(nickT); char* pszText_utf8 = mir_utf8encodeT(gch->ptszText); gg_EnterCriticalSection(&sess_mutex, "gc_event", 57, "sess_mutex", 1); gg_send_message_confer(sess, GG_CLASS_CHAT, chat->recipients_count, chat->recipients, (BYTE*)pszText_utf8); gg_LeaveCriticalSection(&sess_mutex, "gc_event", 57, 1, "sess_mutex", 1); mir_free(pszText_utf8); return 1; } // Privmessage selected if (gch->pDest->iType == GC_USER_PRIVMESS) { HANDLE hContact = NULL; if ((uin = _ttoi(gch->ptszUID)) && (hContact = getcontact(uin, 1, 0, NULL))) CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0); } debugLog(_T("gc_event(): Unhandled event %d, chat %x, uin %d, text \"%s\"."), gch->pDest->iType, chat, uin, gch->ptszText); return 0; }
// IDocHostUIHandler STDMETHODIMP IEView::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdTarget, IDispatch *pdispReserved) { IOleCommandTarget * pOleCommandTarget; IOleWindow * pOleWindow; HWND hSPWnd; if (builder == NULL) { // return S_OK; } #ifdef GECKO { return E_NOTIMPL; /* HMENU hMenu; hMenu = GetSubMenu(LoadMenu(hInstance, MAKEINTRESOURCE(IDR_CONTEXTMENU)),0); CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)hMenu,0); if (dwID == 6) { // anchor EnableMenuItem(hMenu, ID_MENU_COPYLINK, MF_BYCOMMAND | MF_ENABLED); } else if (dwID == 5) { // text select EnableMenuItem(hMenu, ID_MENU_COPY, MF_BYCOMMAND | MF_ENABLED); } else if (dwID == 1) { // control (image) EnableMenuItem(hMenu, ID_MENU_SAVEIMAGE, MF_BYCOMMAND | MF_ENABLED); } if (builder!=NULL) { } int iSelection = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, ppt->x, ppt->y, 0, hwnd, (RECT*)NULL); DestroyMenu(hMenu); if (iSelection == ID_MENU_CLEARLOG) { clear(NULL); } else { SendMessage(hSPWnd, WM_COMMAND, iSelection, (LPARAM) NULL); } */ } #else if (SUCCEEDED(pcmdTarget->QueryInterface(IID_IOleCommandTarget, (void**)&pOleCommandTarget))) { if (SUCCEEDED(pOleCommandTarget->QueryInterface(IID_IOleWindow, (void**)&pOleWindow))) { pOleWindow->GetWindow(&hSPWnd); HMENU hMenu; hMenu = GetSubMenu(LoadMenu(hInstance, MAKEINTRESOURCE(IDR_CONTEXTMENU)),0); CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)hMenu,0); if (dwID == 5) { // anchor EnableMenuItem(hMenu, ID_MENU_COPYLINK, MF_BYCOMMAND | MF_ENABLED); } else if (dwID == 4) { // text select EnableMenuItem(hMenu, ID_MENU_COPY, MF_BYCOMMAND | MF_ENABLED); } else if (dwID == 1) { // control (image) EnableMenuItem(hMenu, ID_MENU_SAVEIMAGE, MF_BYCOMMAND | MF_ENABLED); } if (builder!=NULL) { } int iSelection = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, ppt->x, ppt->y, 0, hwnd, (RECT*)NULL); DestroyMenu(hMenu); if (iSelection == ID_MENU_CLEARLOG) { clear(NULL); } else { SendMessage(hSPWnd, WM_COMMAND, iSelection, (LPARAM) NULL); } pOleWindow->Release(); } pOleCommandTarget->Release(); } #endif return S_OK; }
int FacebookProto::OnBuildStatusMenu(WPARAM, LPARAM) { char text[200]; mir_strncpy(text, m_szModuleName, 100); char *tDest = text + strlen(text); CLISTMENUITEM mi = { sizeof(mi) }; mi.pszService = text; HGENMENU hRoot = MO_GetProtoRootMenu(m_szModuleName); if (hRoot == NULL) { CLISTMENUITEM miRoot = { sizeof(miRoot) }; miRoot.popupPosition = 500085000; miRoot.hParentMenu = HGENMENU_ROOT; miRoot.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED | (this->isOnline() ? 0 : CMIF_GRAYED); miRoot.icolibItem = GetIconHandle("facebook"); miRoot.ptszName = m_tszUserName; hRoot = m_hMenuRoot = Menu_AddProtoMenuItem(&miRoot); } else { if (m_hMenuRoot) CallService(MO_REMOVEMENUITEM, (WPARAM)m_hMenuRoot, 0); m_hMenuRoot = NULL; } mi.flags = CMIF_CHILDPOPUP | (this->isOnline() ? 0 : CMIF_GRAYED); mi.position = 201001; mi.hParentMenu = hRoot; //CreateProtoService(m_szModuleName,"/Mind",&FacebookProto::OnMind,this); strcpy(tDest, "/Mind"); mi.pszName = LPGEN("Share status..."); mi.icolibItem = GetIconHandle("mind"); m_hStatusMind = Menu_AddProtoMenuItem(&mi); //CreateProtoService("/VisitProfile",&FacebookProto::VisitProfile); strcpy(tDest, "/VisitProfile"); mi.flags = CMIF_CHILDPOPUP; mi.pszName = LPGEN("Visit profile"); mi.icolibItem = LoadSkinnedIconHandle(SKINICON_EVENT_URL); // TODO RM: remember and properly free in destructor? /*m_hStatusMind = */Menu_AddProtoMenuItem(&mi); //CreateProtoService("/VisitNotifications", &FacebookProto::VisitNotifications); strcpy(tDest, "/VisitNotifications"); mi.pszName = LPGEN("Visit notifications"); mi.icolibItem = LoadSkinnedIconHandle(SKINICON_EVENT_URL); Menu_AddProtoMenuItem(&mi); // Services... mi.pszName = LPGEN("Services..."); strcpy(tDest, "/Services"); mi.flags = CMIF_CHILDPOPUP | (this->isOnline() ? 0 : CMIF_GRAYED); mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_HELP); m_hMenuServicesRoot = Menu_AddProtoMenuItem(&mi); CreateProtoService("/RefreshBuddyList", &FacebookProto::RefreshBuddyList); strcpy(tDest, "/RefreshBuddyList"); mi.flags = CMIF_ROOTHANDLE; mi.pszName = LPGEN("Refresh Buddy List"); mi.pszPopupName = LPGEN("Services"); mi.icolibItem = GetIconHandle("friendship"); mi.hParentMenu = m_hMenuServicesRoot; Menu_AddProtoMenuItem(&mi); CreateProtoService("/CheckFriendRequests", &FacebookProto::CheckFriendRequests); strcpy(tDest, "/CheckFriendRequests"); mi.flags = CMIF_ROOTHANDLE; mi.pszName = LPGEN("Check Friends Requests"); mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_REQUEST); mi.hParentMenu = m_hMenuServicesRoot; Menu_AddProtoMenuItem(&mi); CreateProtoService("/CheckNewsfeeds", &FacebookProto::CheckNewsfeeds); strcpy(tDest, "/CheckNewsfeeds"); mi.flags = CMIF_ROOTHANDLE; mi.pszName = LPGEN("Check Newsfeeds"); mi.pszPopupName = LPGEN("Services"); mi.icolibItem = GetIconHandle("newsfeed"); mi.hParentMenu = m_hMenuServicesRoot; Menu_AddProtoMenuItem(&mi); return 0; }
static VOID CALLBACK SortContactsTimer(HWND hwnd, UINT message, UINT idEvent, DWORD dwTime) { KillTimer(NULL, resortTimerId); resortTimerId = 0; CallService(MS_CLUI_SORTLIST, 0, 0); }
/* add user: ymsgr:addfriend?ID send message: ymsgr:sendim?ID&m=MESSAGE add chatroom: ymsgr:chat?ROOM */ static INT_PTR ServiceParseYmsgrLink(WPARAM wParam, LPARAM lParam) { TCHAR *arg = (TCHAR*)lParam; if (arg == NULL) return 1; /* sanity check */ /* skip leading prefix */ arg = _tcschr(arg, ':'); if (arg == NULL) return 1; /* parse failed */ for (++arg; *arg == '/'; ++arg) {} if (g_instances.getCount() == 0) return 0; CYahooProto *proto = g_instances[0]; for (int i = 0; i < g_instances.getCount(); ++i) { if (g_instances[i]->m_iStatus > ID_STATUS_OFFLINE) { proto = g_instances[i]; break; } } if (!proto) return 1; /* add a contact to the list */ if (!_tcsnicmp(arg, _T("addfriend?"), 10)) { arg += 10; char *id = get_buddy(&arg); if (!id) return 1; if (proto->getbuddyH(id) == NULL) /* does not yet check if id is current user */ { ADDCONTACTSTRUCT acs = {0}; PROTOSEARCHRESULT psr = {0}; acs.handleType = HANDLE_SEARCHRESULT; acs.szProto = proto->m_szModuleName; acs.psr = &psr; psr.cbSize = sizeof(PROTOSEARCHRESULT); psr.id = (TCHAR*)id; CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs); } mir_free(id); return 0; } /* send a message to a contact */ else if (!_tcsnicmp(arg, _T("sendim?"), 7)) { arg += 7; char *id = get_buddy(&arg); if (!id) return 1; TCHAR *msg = NULL; while (arg) { if (!_tcsnicmp(arg, _T("m="), 2)) { msg = arg + 2; url_decode(msg); break; } arg = _tcschr(arg + 1, '&'); /* first token */ if (arg) *arg = 0; } MCONTACT hContact = proto->add_buddy(id, id, 0, PALF_TEMPORARY); /* ensure contact is on list */ if (hContact) CallService(MS_MSG_SENDMESSAGET, hContact, (LPARAM)msg); mir_free(id); return 0; } /* open a chatroom */ else if (!_tcsnicmp(arg, _T("chat?"), 5)) { arg += 5; // char *id = get_buddy(&arg); // if (!id) return 1; /* not yet implemented (rm contains name of chatroom)*/ return 0; } return 1; /* parse failed */ }
void InitFonts() { colourBg.cbSize = sizeof(ColourIDT); _tcscpy(colourBg.group, LPGENT("Tooltips")); _tcscpy(colourBg.name, LPGENT("Background")); strcpy(colourBg.dbSettingsGroup, MODULE); strcpy(colourBg.setting, "ColourBg"); colourBg.defcolour = RGB(219, 219, 219); colourBg.order = 0; colourBorder.cbSize = sizeof(ColourIDT); _tcscpy(colourBorder.group, LPGENT("Tooltips")); _tcscpy(colourBorder.name, LPGENT("Border")); strcpy(colourBorder.dbSettingsGroup, MODULE); strcpy(colourBorder.setting, "BorderCol"); colourBorder.defcolour = 0; colourBorder.order = 0; colourAvatarBorder.cbSize = sizeof(ColourIDT); _tcscpy(colourAvatarBorder.group, LPGENT("Tooltips")); _tcscpy(colourAvatarBorder.name, LPGENT("Avatar border")); strcpy(colourAvatarBorder.dbSettingsGroup, MODULE); strcpy(colourAvatarBorder.setting, "AvBorderCol"); colourAvatarBorder.defcolour = 0; colourAvatarBorder.order = 0; colourDivider.cbSize = sizeof(ColourIDT); _tcscpy(colourDivider.group, LPGENT("Tooltips")); _tcscpy(colourDivider.name, LPGENT("Dividers")); strcpy(colourDivider.dbSettingsGroup, MODULE); strcpy(colourDivider.setting, "DividerCol"); colourDivider.defcolour = 0; colourDivider.order = 0; colourSidebar.cbSize = sizeof(ColourIDT); _tcscpy(colourSidebar.group, LPGENT("Tooltips")); _tcscpy(colourSidebar.name, LPGENT("Sidebar")); strcpy(colourSidebar.dbSettingsGroup, MODULE); strcpy(colourSidebar.setting, "SidebarCol"); colourSidebar.defcolour = RGB(192, 192, 192); colourSidebar.order = 0; CallService(MS_COLOUR_REGISTERT, (WPARAM)&colourBg, 0); CallService(MS_COLOUR_REGISTERT, (WPARAM)&colourBorder, 0); CallService(MS_COLOUR_REGISTERT, (WPARAM)&colourAvatarBorder, 0); CallService(MS_COLOUR_REGISTERT, (WPARAM)&colourDivider, 0); CallService(MS_COLOUR_REGISTERT, (WPARAM)&colourSidebar, 0); fontTitle.cbSize = sizeof(FontIDT); fontTitle.flags = FIDF_ALLOWEFFECTS; _tcscpy(fontTitle.group, LPGENT("Tooltips")); _tcscpy(fontTitle.name, LPGENT("Title")); strcpy(fontTitle.dbSettingsGroup, MODULE); strcpy(fontTitle.prefix, "FontFirst"); _tcscpy(fontTitle.backgroundGroup, LPGENT("Tooltips")); _tcscpy(fontTitle.backgroundName, LPGENT("Background")); fontTitle.order = 0; _tcscpy(fontTitle.deffontsettings.szFace, _T("Verdana")); fontTitle.deffontsettings.charset = DEFAULT_CHARSET; fontTitle.deffontsettings.size = -16; fontTitle.deffontsettings.style = DBFONTF_BOLD; fontTitle.deffontsettings.colour = RGB(255, 0, 0); fontTitle.flags |= FIDF_DEFAULTVALID; fontLabels.cbSize = sizeof(FontIDT); fontLabels.flags = FIDF_ALLOWEFFECTS; _tcscpy(fontLabels.group, LPGENT("Tooltips")); _tcscpy(fontLabels.name, LPGENT("Labels")); strcpy(fontLabels.dbSettingsGroup, MODULE); strcpy(fontLabels.prefix, "FontLabels"); _tcscpy(fontLabels.backgroundGroup, LPGENT("Tooltips")); _tcscpy(fontLabels.backgroundName, LPGENT("Background")); fontLabels.order = 1; _tcscpy(fontLabels.deffontsettings.szFace, _T("Verdana")); fontLabels.deffontsettings.charset = DEFAULT_CHARSET; fontLabels.deffontsettings.size = -11; fontLabels.deffontsettings.style = DBFONTF_BOLD; fontLabels.deffontsettings.colour = RGB(128, 128, 128); fontLabels.flags |= FIDF_DEFAULTVALID; fontValues.cbSize = sizeof(FontIDT); fontValues.flags = FIDF_ALLOWEFFECTS; _tcscpy(fontValues.group, LPGENT("Tooltips")); _tcscpy(fontValues.name, LPGENT("Values")); strcpy(fontValues.dbSettingsGroup, MODULE); strcpy(fontValues.prefix, "FontValues"); _tcscpy(fontValues.backgroundGroup, LPGENT("Tooltips")); _tcscpy(fontValues.backgroundName, LPGENT("Background")); fontValues.order = 2; _tcscpy(fontValues.deffontsettings.szFace, _T("Verdana")); fontValues.deffontsettings.charset = DEFAULT_CHARSET; fontValues.deffontsettings.size = -11; fontValues.deffontsettings.style = 0; fontValues.deffontsettings.colour = RGB(0, 0, 0); fontValues.flags |= FIDF_DEFAULTVALID; fontTrayTitle.cbSize = sizeof(FontIDT); fontTrayTitle.flags = FIDF_ALLOWEFFECTS; _tcscpy(fontTrayTitle.group, LPGENT("Tooltips")); _tcscpy(fontTrayTitle.name, LPGENT("Tray title")); strcpy(fontTrayTitle.dbSettingsGroup, MODULE); strcpy(fontTrayTitle.prefix, "FontTrayTitle"); _tcscpy(fontTrayTitle.backgroundGroup, LPGENT("Tooltips")); _tcscpy(fontTrayTitle.backgroundName, LPGENT("Background")); fontTrayTitle.order = 0; _tcscpy(fontTrayTitle.deffontsettings.szFace, _T("Verdana")); fontTrayTitle.deffontsettings.charset = DEFAULT_CHARSET; fontTrayTitle.deffontsettings.size = -13; fontTrayTitle.deffontsettings.style = DBFONTF_BOLD; fontTrayTitle.deffontsettings.colour = RGB(0, 0, 0); fontTrayTitle.flags |= FIDF_DEFAULTVALID; CallService(MS_FONT_REGISTERT, (WPARAM)&fontTitle, 0); CallService(MS_FONT_REGISTERT, (WPARAM)&fontLabels, 0); CallService(MS_FONT_REGISTERT, (WPARAM)&fontValues, 0); CallService(MS_FONT_REGISTERT, (WPARAM)&fontTrayTitle, 0); HookEvent(ME_FONT_RELOAD, ReloadFont); }
/** * Enable or disable the replacement of clist extra icons. * * @param bEnable - determines whether icons are enabled or not * @param bUpdateDB - if true the database setting is updated, too. **/ VOID SvcHomepageEnableExtraIcons(BOOLEAN bEnable, BOOLEAN bUpdateDB) { if (myGlobals.HaveCListExtraIcons) { if (bUpdateDB) { DB::Setting::WriteByte(SET_CLIST_EXTRAICON_HOMEPAGE, bEnable); } if (bEnable) { // hook events if (hChangedHook == NULL) { hChangedHook = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, (MIRANDAHOOK)OnContactSettingChanged); } if (hApplyIconHook == NULL) { hApplyIconHook = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, (MIRANDAHOOK)OnCListApplyIcons); } if (myGlobals.ExtraIconsServiceExist) { if (ghExtraIconSvc == INVALID_HANDLE_VALUE) { EXTRAICON_INFO ico; ZeroMemory(&ico, sizeof(ico)); ico.cbSize = sizeof(ico); ico.type = EXTRAICON_TYPE_ICOLIB; ico.name = "homepage"; //must be the same as the group name in extraicon ico.description = "Homepage (uinfoex)"; ico.descIcon = ICO_BTN_GOTO; ghExtraIconSvc = (HANDLE)CallService(MS_EXTRAICON_REGISTER, (WPARAM)&ico, 0); } } else if (hRebuildIconsHook == NULL) { hRebuildIconsHook = HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, OnCListRebuildIcons); OnCListRebuildIcons(0, 0); } } else { if (hChangedHook) { UnhookEvent(hChangedHook); hChangedHook = NULL; } if (hApplyIconHook) { UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; } if (hRebuildIconsHook) { UnhookEvent(hRebuildIconsHook); hRebuildIconsHook = NULL; } } SvcHomepageApplyCListIcons(); } }
void MirfoxData::initializeMirandaAccounts() { clearMirandaAccounts(); int accountsCount = 0; PROTOACCOUNT **accounts; //get accounts from Miranda by CallService MS_PROTO_ENUMACCOUNTS CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&accountsCount, (LPARAM)&accounts); uint64_t protocolId = 1; for(int i=0; i<accountsCount; i++) { //checking account if(accounts[i]->bIsEnabled == 0){ continue; } if(accounts[i]->bDynDisabled != 0){ continue; } //add to list MirandaAccount* mirandaAccountItemPtr = new MirandaAccount( protocolId, accounts[i]->szModuleName, accounts[i]->tszAccountName, accounts[i]->szProtoName, accounts[i]->iOrder ); MFLogger* logger = MFLogger::getInstance(); logger->log_p(L"initializeMirandaAccounts: tszAccountName: [%s] protocol: [%S]", accounts[i]->tszAccountName, accounts[i]->szProtoName ); protocolId++; std::string mirandaAccountDBKey("ACCOUNTSTATE_"); mirandaAccountDBKey += accounts[i]->szModuleName; int keyValue = db_get_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 0); if (keyValue == 1 || keyValue == 2){ //setting exist if (keyValue == 1){ mirandaAccountItemPtr->accountState = MFENUM_MIRANDAACCOUNT_STATE_ON; //1 } else { mirandaAccountItemPtr->accountState = MFENUM_MIRANDAACCOUNT_STATE_OFF; //2 } } else { //setting does not exist, or is invalid -> save default setting (1 - ON) if (MirfoxData::getAccountDefaultState(mirandaAccountItemPtr) == 1){ //on = 1 mirandaAccountItemPtr->accountState = MFENUM_MIRANDAACCOUNT_STATE_ON; //1 db_set_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 1); } else { //off = 2 mirandaAccountItemPtr->accountState = MFENUM_MIRANDAACCOUNT_STATE_OFF; //2 db_set_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 2); } } addMirandaAccount(mirandaAccountItemPtr); } //TODO - sort by mirandaAccount.displayOrder }
int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, TCHAR **szData) { if (userAgent == NULL || userAgent[0] == 0) userAgent = NETLIB_USER_AGENT; NETLIBHTTPHEADER headers[5]; headers[0].szName = "User-Agent"; headers[0].szValue = userAgent; headers[1].szName = "Cache-Control"; headers[1].szValue = "no-cache"; headers[2].szName = "Pragma"; headers[2].szValue = "no-cache"; headers[3].szName = "Connection"; headers[3].szValue = "close"; headers[4].szName = "Cookie"; headers[4].szValue = cookie; // initialize the netlib request NETLIBHTTPREQUEST nlhr = { sizeof(nlhr) }; nlhr.requestType = REQUEST_GET; nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_PERSISTENT | NLHRF_REDIRECT; nlhr.szUrl = szUrl; nlhr.nlc = hNetlibHttp; nlhr.headers = headers; nlhr.headersCount = _countof(headers); if (cookie == NULL || cookie[0] == 0) --nlhr.headersCount; // download the page NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr); if (nlhrReply == 0) { // if the data does not downloaded successfully (ie. disconnected), then return 1000 as error code *szData = (TCHAR*)mir_alloc(512); // store the error code in szData mir_tstrcpy(*szData, _T("NetLib error occurred!!")); hNetlibHttp = NULL; return NLHRF_REDIRECT; } // if the recieved code is 200 OK int result; if (nlhrReply->resultCode == 200) { if (nlhrReply->dataLength) { bool bIsUtf = false; result = 0; // allocate memory and save the retrieved data int i = findHeader(nlhrReply, "Content-Type"); if (i != -1 && strstr(_strlwr((char*)nlhrReply->headers[i].szValue), "utf-8")) bIsUtf = true; else { char* end = nlhrReply->pData; for (;;) { char* beg = strstr(end, "<meta"); if (beg == NULL) break; else { char* method, tmp; end = strchr(beg, '>'); tmp = *end; *end = 0; method = strstr(beg, "http-equiv=\""); if (method && _strnicmp(method + 12, "Content-Type", 12) == 0 && strstr(method, "utf-8")) { bIsUtf = true; break; } else *end = tmp; } } } TCHAR *retVal = NULL; if (bIsUtf) retVal = mir_utf8decodeT(nlhrReply->pData); if (retVal == NULL) retVal = mir_a2t(nlhrReply->pData); *szData = retVal; } else result = DATA_EMPTY; } // return error code if the recieved code is neither 200 OK nor 302 Moved else { *szData = (TCHAR*)mir_alloc(512); // store the error code in szData mir_sntprintf(*szData, 512, _T("Error occured! HTTP Error: %i\n"), nlhrReply->resultCode); result = (int)nlhrReply->resultCode; } hNetlibHttp = nlhrReply->nlc; // make a copy of the retrieved data, then free the memory of the http reply CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); return result; }
void MirfoxData::initializeMirandaContacts() { MFLogger* logger = MFLogger::getInstance(); //clean data clearMirandaContacts(); //get contects from miranda for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)){ //add to list MirandaContact* mirandaContactItemPtr = new MirandaContact( hContact //handle to contact in miranda ); addMirandaContact(mirandaContactItemPtr); } boost::ptr_list<MirandaContact>* mirandaContactsPtr = getMirandaContacts(); boost::ptr_list<MirandaContact>::iterator mirandaContactsIter; //determine contact's account for (mirandaContactsIter = mirandaContactsPtr->begin(); mirandaContactsIter != mirandaContactsPtr->end(); mirandaContactsIter++){ logger->log_p(L"initializeMirandaContacts: try to get account for hContact = [" SCNuPTR L"]", mirandaContactsIter->contactHandle); char* szModuleName = (char*)CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM)(mirandaContactsIter->contactHandle), 0); if (szModuleName == NULL){ continue; //mirandaContactsIter->mirandaAccountPtr will be NULL } mirandaContactsIter->mirandaAccountPtr = getMirandaAccountPtrBySzModuleName(szModuleName); } //determine contact's name for (mirandaContactsIter = mirandaContactsPtr->begin(); mirandaContactsIter != mirandaContactsPtr->end(); mirandaContactsIter++){ logger->log_p(L"initializeMirandaContacts: try to get name for hContact = [" SCNuPTR L"]", mirandaContactsIter->contactHandle); if (mirandaContactsIter->mirandaAccountPtr != NULL){ if ( strcmp(mirandaContactsIter->mirandaAccountPtr->szProtoName, "Twitter") == 0){ //hack for Twitter protocol DBVARIANT dbv; if (!db_get_s(mirandaContactsIter->contactHandle, mirandaContactsIter->mirandaAccountPtr->szModuleName, "Username", &dbv, DBVT_WCHAR)) { mirandaContactsIter->contactNameW = std::wstring(dbv.pwszVal); db_free(&dbv); } } else { //standard miranda way for another protocols mirandaContactsIter->contactNameW = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)mirandaContactsIter->contactHandle, GCDNF_TCHAR); //get contact's display name from clist } } if (mirandaContactsIter->contactNameW.size() == 0){ //last chance (if some hack didn't work or mirandaContactsIter->mirandaAccountPtr is NULL) mirandaContactsIter->contactNameW = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)mirandaContactsIter->contactHandle, GCDNF_TCHAR); //get contact's display name from clist } logger->log_p(L"initializeMirandaContacts: got name for hContact = [" SCNuPTR L"] is: [%s]", mirandaContactsIter->contactHandle, &(mirandaContactsIter->contactNameW)==NULL ? L"<null>" : mirandaContactsIter->contactNameW.c_str()); } //determine contact's state for (mirandaContactsIter = mirandaContactsPtr->begin(); mirandaContactsIter != mirandaContactsPtr->end(); mirandaContactsIter++){ logger->log_p(L"initializeMirandaContacts: try to get state for hContact = [" SCNuPTR L"]", mirandaContactsIter->contactHandle); int keyValue = db_get_b(mirandaContactsIter->contactHandle, PLUGIN_DB_ID, "state", 0); if (keyValue == 1 || keyValue == 2){ //setting exist if (keyValue == 1){ mirandaContactsIter->contactState = MFENUM_MIRANDACONTACT_STATE_ON; //1 } else { mirandaContactsIter->contactState = MFENUM_MIRANDACONTACT_STATE_OFF; //2 } } else { //setting does not exist, or is invalid -> save default setting (1 - ON) if (MirfoxData::getContactDefaultState(mirandaContactsIter->getObjectPtr()) == 1){ //on = 1 mirandaContactsIter->contactState = MFENUM_MIRANDACONTACT_STATE_ON; //1 db_set_b(mirandaContactsIter->contactHandle, PLUGIN_DB_ID, "state", 1); } else { //off = 2 mirandaContactsIter->contactState = MFENUM_MIRANDACONTACT_STATE_OFF; //2 db_set_b(mirandaContactsIter->contactHandle, PLUGIN_DB_ID, "state", 2); } } } }
char* CMsnProto::getSslResult(char** parUrl, const char* parAuthInfo, const char* hdrs, unsigned& status) { mHttpsTS = clock(); char* result = NULL; NETLIBHTTPREQUEST nlhr = {0}; // initialize the netlib request nlhr.cbSize = sizeof(nlhr); nlhr.requestType = REQUEST_POST; nlhr.flags = NLHRF_HTTP11 | NLHRF_DUMPASTEXT | NLHRF_PERSISTENT | NLHRF_REDIRECT; nlhr.szUrl = *parUrl; nlhr.dataLength = (int)strlen(parAuthInfo); nlhr.pData = (char*)parAuthInfo; nlhr.nlc = hHttpsConnection; #ifndef _DEBUG if (strstr(*parUrl, "login")) nlhr.flags |= NLHRF_NODUMPSEND; #endif nlhr.headersCount = 4; nlhr.headers=(NETLIBHTTPHEADER*)alloca(sizeof(NETLIBHTTPHEADER) * (nlhr.headersCount + 5)); nlhr.headers[0].szName = "User-Agent"; nlhr.headers[0].szValue = (char*)MSN_USER_AGENT; nlhr.headers[1].szName = "Accept"; nlhr.headers[1].szValue = "text/*"; nlhr.headers[2].szName = "Content-Type"; nlhr.headers[2].szValue = "text/xml; charset=utf-8"; nlhr.headers[3].szName = "Cache-Control"; nlhr.headers[3].szValue = "no-cache"; if (hdrs) { unsigned count = 0; char* hdrprs = NEWSTR_ALLOCA(hdrs); for (;;) { char* fnd = strchr(hdrprs, ':'); if (fnd == NULL) break; *fnd = 0; fnd += 2; nlhr.headers[nlhr.headersCount].szName = hdrprs; nlhr.headers[nlhr.headersCount].szValue = fnd; fnd = strchr(fnd, '\r'); *fnd = 0; hdrprs = fnd + 2; ++nlhr.headersCount; if (++count >= 5) break; } } // download the page NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUserHttps,(LPARAM)&nlhr); if (nlhrReply) { hHttpsConnection = nlhrReply->nlc; status = nlhrReply->resultCode; if (nlhrReply->szUrl) { mir_free(*parUrl); *parUrl = nlhrReply->szUrl; nlhrReply->szUrl = NULL; } result = nlhrReply->pData; nlhrReply->dataLength = 0; nlhrReply->pData = NULL; CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply); } else hHttpsConnection = NULL; mHttpsTS = clock(); return result; }
void SendMsgDialog( HWND hwnd, TCHAR *pText ) { ThumbInfo *pThumb = thumbList.FindThumb( hwnd ); if ( pThumb != NULL ) CallService(MS_MSG_SENDMESSAGET, (WPARAM)pThumb->hContact, (LPARAM)pText ); }
void showmsgwnd(unsigned int param) { logmsg("showmsgwnd"); if (db_get_b(NULL,THIS_MODULE, "showMessageWindow", DEFAULT_SHOWMSGWIN)) CallService(MS_MSG_SENDMESSAGET, (WPARAM)param, 0); }
static LRESULT __stdcall CommWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { ThumbInfo *pThumb = thumbList.FindThumb(hwnd); switch(uMsg) { case WM_RBUTTONUP: { POINT pt; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); if (pThumb) pThumb->ThumbDeselect(TRUE); ClientToScreen(hwnd, &pt); ShowContactMenu( hwnd, pt ); } break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_NCPAINT: if (pThumb) { HDC hdc = GetWindowDC( hwnd ); BitBlt(hdc, 0, 0, pThumb->bmpContent.getWidth(), pThumb->bmpContent.getHeight(), pThumb->bmpContent.getDC(), 0, 0, SRCCOPY); //RepaintWindow( hwnd, hdc ); ReleaseDC( hwnd, hdc ); ValidateRect( hwnd, NULL ); return 0; } case WM_PAINT: if (pThumb) { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); BitBlt(hdc, 0, 0, pThumb->bmpContent.getWidth(), pThumb->bmpContent.getHeight(), pThumb->bmpContent.getDC(), 0, 0, SRCCOPY); //RepaintWindow( hwnd, hdc ); EndPaint(hwnd, &ps); break; } case WM_PRINT: case WM_PRINTCLIENT: if (pThumb) { BitBlt((HDC)wParam, 0, 0, pThumb->bmpContent.getWidth(), pThumb->bmpContent.getHeight(), pThumb->bmpContent.getDC(), 0, 0, SRCCOPY); //RepaintWindow(hwnd, (HDC)wParam); break; } case WM_MEASUREITEM: CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); break; case WM_DRAWITEM: CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); break; case WM_LBUTTONDOWN: if (pThumb) pThumb->OnLButtonDown( LOWORD(lParam), HIWORD(lParam)); break; case WM_MOUSEMOVE: if (pThumb) pThumb->OnMouseMove( LOWORD(lParam), HIWORD(lParam), wParam); break; case WM_LBUTTONUP: if (pThumb) pThumb->OnLButtonUp(); break; case WM_LBUTTONDBLCLK: // Popup message dialog if (!fcOpt.bUseSingleClick && pThumb) pThumb->PopupMessageDialog(); break; case WM_RBUTTONDOWN: if (bEnableTip && fcOpt.bShowTip && pThumb) pThumb->KillTip(); break; case WM_REFRESH_CONTACT: if (pThumb) { _tcsncpy( pThumb->ptszName, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)pThumb->hContact, (LPARAM)GCDNF_TCHAR ), USERNAME_LEN - 1); pThumb->RefreshContactStatus((int)lParam); pThumb->ResizeThumb(); } break; case WM_TIMER: if (pThumb) pThumb->OnTimer(wParam); break; case WM_HOTKEY: ThumbInfo *pThumb = thumbList.FindThumb((HWND)wParam); if (pThumb) pThumb->PopupMessageDialog(); } return DefWindowProc(hwnd, uMsg, wParam, lParam); }
static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static int noRecursion=0; switch(msg) { case WM_INITDIALOG: { char *szText=(char*)lParam; int i,item,countryCount; struct CountryListEntry *countries; SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)lParam); if(szText[0]) SetWindowText(hwndDlg,TranslateT("Edit Phone Number")); TranslateDialogDefault(hwndDlg); if(lstrlenA(szText)>4 && !lstrcmpA(szText+lstrlenA(szText)-4," SMS")) { CheckDlgButton(hwndDlg,IDC_SMS,BST_CHECKED); szText[lstrlenA(szText)-4]='\0'; } EnableWindow(GetDlgItem(hwndDlg,IDOK),szText[0]); SendDlgItemMessage(hwndDlg,IDC_AREA,EM_LIMITTEXT,31,0); SendDlgItemMessage(hwndDlg,IDC_NUMBER,EM_LIMITTEXT,63,0); CallService(MS_UTILS_GETCOUNTRYLIST,(WPARAM)&countryCount,(LPARAM)&countries); for(i=0;i<countryCount;i++) { if(countries[i].id==0 || countries[i].id==0xFFFF) continue; item=SendDlgItemMessageA(hwndDlg,IDC_COUNTRY,CB_ADDSTRING,0,(LPARAM)Translate(countries[i].szName)); SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_SETITEMDATA,item,countries[i].id); } SetDlgItemTextA(hwndDlg,IDC_PHONE,szText); return TRUE; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: { char *szText=(char*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); int isValid=1; GetDlgItemTextA(hwndDlg,IDC_PHONE,szText,252); if(lstrlenA(szText)<7 || szText[0]!='+') isValid=0; if(isValid) isValid=(lstrlenA(szText+1)==(int)strspn(szText+1,"0123456789 ()-")); if(!isValid) { MessageBox(hwndDlg,TranslateT("The phone number should start with a + and consist of numbers, spaces, brackets and hyphens only."),TranslateT("Invalid Phone Number"),MB_OK); break; } if(IsDlgButtonChecked(hwndDlg,IDC_SMS)) lstrcatA(szText," SMS"); } //fall through case IDCANCEL: EndDialog(hwndDlg,wParam); case IDC_COUNTRY: if(HIWORD(wParam)!=CBN_SELCHANGE) break; case IDC_AREA: case IDC_NUMBER: if(LOWORD(wParam)!=IDC_COUNTRY && HIWORD(wParam)!=EN_CHANGE) break; if(noRecursion) break; EnableWindow(GetDlgItem(hwndDlg,IDOK),TRUE); { char szPhone[96],szArea[32],szNumber[64]; GetDlgItemTextA(hwndDlg,IDC_AREA,szArea,SIZEOF(szArea)); GetDlgItemTextA(hwndDlg,IDC_NUMBER,szNumber,SIZEOF(szNumber)); mir_snprintf(szPhone,SIZEOF(szPhone),"+%u (%s) %s",SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_GETITEMDATA,SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_GETCURSEL,0,0),0),szArea,szNumber); noRecursion=1; SetDlgItemTextA(hwndDlg,IDC_PHONE,szPhone); noRecursion=0; } break; case IDC_PHONE: if(HIWORD(wParam)!=EN_UPDATE) break; if(noRecursion) break; noRecursion=1; { char szText[256],*pText=NULL,*pArea,*pNumber; int isValid=1; GetDlgItemTextA(hwndDlg,IDC_PHONE,szText,SIZEOF(szText)); if (szText[0] != '+') isValid=0; if ( isValid ) { int i, country = strtol( szText+1, &pText, 10 ); if ( pText - szText > 4 ) isValid = 0; else { for ( i = SendDlgItemMessage( hwndDlg, IDC_COUNTRY, CB_GETCOUNT, 0, 0 )-1; i >= 0; i-- ) if ( country == SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_GETITEMDATA,i,0)) { SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_SETCURSEL,i,0); break; } if ( i < 0 ) isValid = 0; } } if ( isValid ) { pArea = pText+strcspn(pText,"0123456789"); pText = pArea+strspn(pArea,"0123456789"); if(*pText) { *pText='\0'; pNumber = pText+1+strcspn(pText+1,"0123456789"); SetDlgItemTextA(hwndDlg,IDC_NUMBER,pNumber); } SetDlgItemTextA(hwndDlg,IDC_AREA,pArea); } if ( !isValid ) { SendDlgItemMessage(hwndDlg,IDC_COUNTRY,CB_SETCURSEL,-1,0); SetDlgItemTextA(hwndDlg,IDC_AREA,""); SetDlgItemTextA(hwndDlg,IDC_NUMBER,""); } } noRecursion=0; EnableWindow(GetDlgItem(hwndDlg,IDOK),GetWindowTextLength(GetDlgItem(hwndDlg,IDC_PHONE))); break; } break; } return FALSE; }
void CIcqProto::handleServiceFam(BYTE *pBuffer, size_t wBufferLength, snac_header *pSnacHeader, serverthread_info *info) { icq_packet packet; switch (pSnacHeader->wSubtype) { case ICQ_SERVER_READY: debugLogA("Server is ready and is requesting my Family versions"); debugLogA("Sending my Families"); // This packet is a response to SRV_FAMILIES SNAC(1,3). // This tells the server which SNAC families and their corresponding // versions which the client understands. This also seems to identify // the client as an ICQ vice AIM client to the server. // Miranda mimics the behaviour of ICQ 6 serverPacketInit(&packet, 54); packFNACHeader(&packet, ICQ_SERVICE_FAMILY, ICQ_CLIENT_FAMILIES); packDWord(&packet, 0x00220001); packDWord(&packet, 0x00010004); packDWord(&packet, 0x00130004); packDWord(&packet, 0x00020001); packDWord(&packet, 0x00030001); packDWord(&packet, 0x00150001); packDWord(&packet, 0x00040001); packDWord(&packet, 0x00060001); packDWord(&packet, 0x00090001); packDWord(&packet, 0x000a0001); packDWord(&packet, 0x000b0001); sendServPacket(&packet); break; case ICQ_SERVER_FAMILIES2: /* This is a reply to CLI_FAMILIES and it tells the client which families and their versions that this server understands. * We send a rate request packet */ debugLogA("Server told me his Family versions"); debugLogA("Requesting Rate Information"); serverPacketInit(&packet, 10); packFNACHeader(&packet, ICQ_SERVICE_FAMILY, ICQ_CLIENT_REQ_RATE_INFO); sendServPacket(&packet); break; case ICQ_SERVER_RATE_INFO: debugLogA("Server sent Rate Info"); /* init rates management */ m_rates = new rates(this, pBuffer, wBufferLength); /* ack rate levels */ debugLogA("Sending Rate Info Ack"); m_rates->initAckPacket(&packet); sendServPacket(&packet); /* CLI_REQINFO - This command requests from the server certain information about the client that is stored on the server. */ debugLogA("Sending CLI_REQINFO"); serverPacketInit(&packet, 10); packFNACHeader(&packet, ICQ_SERVICE_FAMILY, ICQ_CLIENT_REQINFO); sendServPacket(&packet); if (m_bSsiEnabled) { cookie_servlist_action* ack; DWORD dwCookie; DWORD dwLastUpdate = getDword("SrvLastUpdate", 0); WORD wRecordCount = getWord("SrvRecordCount", 0); // CLI_REQLISTS - we want to use SSI debugLogA("Requesting roster rights"); serverPacketInit(&packet, 16); packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_CLI_REQLISTS); packTLVWord(&packet, 0x0B, 0x000F); // mimic ICQ 6 sendServPacket(&packet); if (!wRecordCount) { // CLI_REQROSTER // we do not have any data - request full list debugLogA("Requesting full roster"); serverPacketInit(&packet, 10); ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)); if (ack) { // we try to use standalone cookie if available ack->dwAction = SSA_CHECK_ROSTER; // loading list dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_CLI_REQUEST, 0, ack); } else // if not use that old fake dwCookie = ICQ_LISTS_CLI_REQUEST << 0x10; packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_CLI_REQUEST, 0, dwCookie); sendServPacket(&packet); } else { // CLI_CHECKROSTER debugLogA("Requesting roster check"); serverPacketInit(&packet, 16); ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)); if (ack) { // TODO: rewrite - use get list service for empty list // we try to use standalone cookie if available ack->dwAction = SSA_CHECK_ROSTER; // loading list dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_CLI_CHECK, 0, ack); } else // if not use that old fake dwCookie = ICQ_LISTS_CLI_CHECK << 0x10; packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_CLI_CHECK, 0, dwCookie); // check if it was not changed elsewhere (force reload, set that setting to zero) if (IsServerGroupsDefined()) { packDWord(&packet, dwLastUpdate); // last saved time packWord(&packet, wRecordCount); // number of records saved } else { // we need to get groups info into DB, force receive list packDWord(&packet, 0); // last saved time packWord(&packet, 0); // number of records saved } sendServPacket(&packet); } } // CLI_REQLOCATION debugLogA("Requesting Location rights"); serverPacketInit(&packet, 10); packFNACHeader(&packet, ICQ_LOCATION_FAMILY, ICQ_LOCATION_CLI_REQ_RIGHTS); sendServPacket(&packet); // CLI_REQBUDDY debugLogA("Requesting Client-side contactlist rights"); serverPacketInit(&packet, 16); packFNACHeader(&packet, ICQ_BUDDY_FAMILY, ICQ_USER_CLI_REQBUDDY); // Query flags: 1 = Enable Avatars // 2 = Enable offline status message notification // 4 = Enable Avatars for offline contacts // 8 = Use reject for not authorized contacts packTLVWord(&packet, 0x05, 0x0007); sendServPacket(&packet); // CLI_REQICBM debugLogA("Sending CLI_REQICBM"); serverPacketInit(&packet, 10); packFNACHeader(&packet, ICQ_MSG_FAMILY, ICQ_MSG_CLI_REQICBM); sendServPacket(&packet); // CLI_REQBOS debugLogA("Sending CLI_REQBOS"); serverPacketInit(&packet, 10); packFNACHeader(&packet, ICQ_BOS_FAMILY, ICQ_PRIVACY_REQ_RIGHTS); sendServPacket(&packet); break; case ICQ_SERVER_PAUSE: debugLogA("Server is going down in a few seconds... (Flags: %u)", pSnacHeader->wFlags); // This is the list of groups that we want to have on the next server serverPacketInit(&packet, 30); packFNACHeader(&packet, ICQ_SERVICE_FAMILY, ICQ_CLIENT_PAUSE_ACK); packWord(&packet, ICQ_SERVICE_FAMILY); packWord(&packet, ICQ_LISTS_FAMILY); packWord(&packet, ICQ_LOCATION_FAMILY); packWord(&packet, ICQ_BUDDY_FAMILY); packWord(&packet, ICQ_EXTENSIONS_FAMILY); packWord(&packet, ICQ_MSG_FAMILY); packWord(&packet, 0x06); packWord(&packet, ICQ_BOS_FAMILY); packWord(&packet, ICQ_LOOKUP_FAMILY); packWord(&packet, ICQ_STATS_FAMILY); sendServPacket(&packet); debugLogA("Sent server pause ack"); break; case ICQ_SERVER_MIGRATIONREQ: debugLogA("Server migration requested (Flags: %u)", pSnacHeader->wFlags); pBuffer += 2; // Unknown, seen: 0 wBufferLength -= 2; { oscar_tlv_chain *chain = readIntoTLVChain(&pBuffer, wBufferLength, 0); if (info->cookieDataLen > 0) SAFE_FREE((void**)&info->cookieData); info->newServer = chain->getString(0x05, 1); info->newServerSSL = chain->getNumber(0x8E, 1); info->cookieData = (BYTE*)chain->getString(0x06, 1); info->cookieDataLen = chain->getLength(0x06, 1); disposeChain(&chain); if (!info->newServer || !info->cookieData) { icq_LogMessage(LOG_FATAL, LPGEN("A server migration has failed because the server returned invalid data. You must reconnect manually.")); SAFE_FREE(&info->newServer); SAFE_FREE((void**)&info->cookieData); info->cookieDataLen = 0; info->isNewServerReady = false; return; } debugLogA("Migration has started. New server will be %s", info->newServer); m_iDesiredStatus = m_iStatus; SetCurrentStatus(ID_STATUS_CONNECTING); // revert to connecting state info->isNewServerReady = info->isMigrating = true; } break; case ICQ_SERVER_NAME_INFO: // This is the reply to CLI_REQINFO debugLogA("Received self info"); { BYTE bUinLen; unpackByte(&pBuffer, &bUinLen); pBuffer += bUinLen; pBuffer += 4; /* warning level & user class */ wBufferLength -= 5 + bUinLen; // This is during the login sequence if (pSnacHeader->dwRef == ICQ_CLIENT_REQINFO << 0x10) { // TLV(x01) User type? // TLV(x0C) Empty CLI2CLI Direct connection info // TLV(x0A) External IP // TLV(x0F) Number of seconds that user has been online // TLV(x03) The online since time. // TLV(x0A) External IP again // TLV(x22) Unknown // TLV(x1E) Unknown: empty. // TLV(x05) Member of ICQ since. // TLV(x14) Unknown oscar_tlv_chain *chain = readIntoTLVChain(&pBuffer, wBufferLength, 0); // Save external IP DWORD dwValue = chain->getDWord(0x0A, 1); setDword("IP", dwValue); // Save member since timestamp dwValue = chain->getDWord(0x05, 1); if (dwValue) setDword("MemberTS", dwValue); dwValue = chain->getDWord(0x03, 1); setDword("LogonTS", dwValue ? dwValue : time(NULL)); disposeChain(&chain); // If we are in SSI mode, this is sent after the list is acked instead // to make sure that we don't set status before seing the visibility code if (!m_bSsiEnabled || info->isMigrating) handleServUINSettings(wListenPort, info); } } break; case ICQ_SERVER_RATE_CHANGE: if (wBufferLength >= 2) { WORD wStatus, wClass; DWORD dwLevel; // We now have global rate management, although controlled are only some // areas. This should not arrive in most cases. If it does, update our // local rate levels & issue broadcast. unpackWord(&pBuffer, &wStatus); unpackWord(&pBuffer, &wClass); pBuffer += 20; unpackDWord(&pBuffer, &dwLevel); m_ratesMutex->Enter(); m_rates->updateLevel(wClass, dwLevel); m_ratesMutex->Leave(); if (wStatus == 2 || wStatus == 3) { // this is only the simplest solution, needs rate management to every section ProtoBroadcastAck(NULL, ICQACKTYPE_RATEWARNING, ACKRESULT_STATUS, (HANDLE)wClass, wStatus); if (wStatus == 2) debugLogA("Rates #%u: Alert", wClass); else debugLogA("Rates #%u: Limit", wClass); } else if (wStatus == 4) { ProtoBroadcastAck(NULL, ICQACKTYPE_RATEWARNING, ACKRESULT_STATUS, (HANDLE)wClass, wStatus); debugLogA("Rates #%u: Clear", wClass); } } break; case ICQ_SERVER_REDIRECT_SERVICE: // reply to family request, got new connection point { oscar_tlv_chain *pChain = NULL; cookie_family_request *pCookieData; if (!(pChain = readIntoTLVChain(&pBuffer, wBufferLength, 0))) { debugLogA("Received Broken Redirect Service SNAC(1,5)."); break; } // pick request data WORD wFamily = pChain->getWord(0x0D, 1); if ((!FindCookie(pSnacHeader->dwRef, NULL, (void**)&pCookieData)) || (pCookieData->wFamily != wFamily)) { disposeChain(&pChain); debugLogA("Received unexpected SNAC(1,5), skipping."); break; } FreeCookie(pSnacHeader->dwRef); // new family entry point received char *pServer = pChain->getString(0x05, 1); BYTE bServerSSL = pChain->getNumber(0x8E, 1); char *pCookie = pChain->getString(0x06, 1); WORD wCookieLen = pChain->getLength(0x06, 1); if (!pServer || !pCookie) { debugLogA("Server returned invalid data, family unavailable."); SAFE_FREE(&pServer); SAFE_FREE(&pCookie); SAFE_FREE((void**)&pCookieData); disposeChain(&pChain); break; } // Get new family server ip and port WORD wPort = info->wServerPort; // get default port parseServerAddress(pServer, &wPort); // establish connection NETLIBOPENCONNECTION nloc = { 0 }; if (m_bGatewayMode) nloc.flags |= NLOCF_HTTPGATEWAY; nloc.szHost = pServer; nloc.wPort = wPort; HANDLE hConnection = NetLib_OpenConnection(m_hNetlibUser, wFamily == ICQ_AVATAR_FAMILY ? "Avatar " : NULL, &nloc); if (hConnection == NULL) debugLogA("Unable to connect to ICQ new family server."); // we want the handler to be called even if the connecting failed else if (bServerSSL) { /* Start SSL session if requested */ debugLogA("(%p) Starting SSL negotiation", CallService(MS_NETLIB_GETSOCKET, (WPARAM)hConnection, 0)); if (!CallService(MS_NETLIB_STARTSSL, (WPARAM)hConnection, 0)) { debugLogA("Unable to connect to ICQ new family server, SSL could not be negotiated"); NetLib_CloseConnection(&hConnection, FALSE); } } (this->*pCookieData->familyHandler)(hConnection, pCookie, wCookieLen); // Free allocated memory // NOTE: "cookie" will get freed when we have connected to the avatar server. disposeChain(&pChain); SAFE_FREE(&pServer); SAFE_FREE((void**)&pCookieData); break; } case ICQ_SERVER_EXTSTATUS: // our session data debugLogA("Received owner session data."); while (wBufferLength > 4) { // loop thru all items WORD itemType = pBuffer[0] * 0x10 | pBuffer[1]; BYTE itemFlags = pBuffer[2]; size_t itemLen = pBuffer[3]; if (itemType == AVATAR_HASH_PHOTO) { /// TODO: handle photo item // skip photo item debugLogA("Photo item recognized"); } else if ((itemType == AVATAR_HASH_STATIC || itemType == AVATAR_HASH_FLASH) && (itemLen >= 0x10)) { debugLogA("Avatar item recognized"); if (m_bAvatarsEnabled && !info->bMyAvatarInited) { // signal the server after login // this refreshes avatar state - it used to work automatically, but now it does not if (getByte("ForceOurAvatar", 0)) { // keep our avatar TCHAR *file = GetOwnAvatarFileName(); SetMyAvatar(0, (LPARAM)file); SAFE_FREE(&file); } else { // only change avatar hash to the same one BYTE hash[0x14]; memcpy(hash, pBuffer, 0x14); hash[2] = 1; // update image status updateServAvatarHash(hash, 0x14); } info->bMyAvatarInited = true; break; } // process owner avatar hash changed notification handleAvatarOwnerHash(itemFlags, pBuffer, itemLen + 4); } else if (itemType == 0x02) { debugLogA("Status message item recognized"); } else if (itemType == 0x0E) { debugLogA("Status mood item recognized"); } // move to next item if (wBufferLength >= itemLen + 4) { wBufferLength -= itemLen + 4; pBuffer += itemLen + 4; } else { pBuffer += wBufferLength; wBufferLength = 0; } } break; case ICQ_ERROR: // Something went wrong, probably the request for avatar family failed { WORD wError; if (wBufferLength >= 2) unpackWord(&pBuffer, &wError); else wError = 0; LogFamilyError(ICQ_SERVICE_FAMILY, wError); } break; // Stuff we don't care about case ICQ_SERVER_MOTD: debugLogA("Server message of the day"); break; default: debugLogA("Warning: Ignoring SNAC(x%02x,x%02x) - Unknown SNAC (Flags: %u, Ref: %u)", ICQ_SERVICE_FAMILY, pSnacHeader->wSubtype, pSnacHeader->wFlags, pSnacHeader->dwRef); break; } }