void Protocol::GetStatusMsg(int aStatus, char *msg, size_t msg_size) { if (!CanGetStatusMsg()) { lstrcpyn(msg, "", msg_size); return; } bool isCurrentStatus = (aStatus == GetStatus()); if (isCurrentStatus && CanCall(PS_GETMYAWAYMSG)) { char *tmp = (char *) Call(PS_GETMYAWAYMSG); lstrcpyn(msg, tmp == NULL ? "" : tmp, msg_size); } else if (isCurrentStatus && ServiceExists(MS_SA_ISSARUNNING) && CallService(MS_SA_ISSARUNNING, 0, 0)) { char *tmp = (char *) CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM) ID_STATUS_CURRENT, (LPARAM) name.c_str()); if (tmp != NULL) { lstrcpyn(msg, tmp, msg_size); mir_free(tmp); } else lstrcpyn(msg, "", msg_size); } else if (ServiceExists(MS_NAS_GETSTATE)) { NAS_PROTOINFO pi; ZeroMemory(&pi, sizeof(pi)); pi.cbSize = sizeof(NAS_PROTOINFO); pi.szProto = (char *) name.c_str(); pi.status = (isCurrentStatus ? 0 : aStatus); pi.szMsg = NULL; if (CallService(MS_NAS_GETSTATE, (WPARAM) &pi, 1) == 0) { if (pi.szMsg == NULL) { pi.szProto = NULL; if (CallService(MS_NAS_GETSTATE, (WPARAM) &pi, 1) == 0) { if (pi.szMsg != NULL) { lstrcpyn(msg, pi.szMsg, msg_size); mir_free(pi.szMsg); } else lstrcpyn(msg, "", msg_size); } else lstrcpyn(msg, "", msg_size); } else // if (pi.szMsg != NULL) { lstrcpyn(msg, pi.szMsg, msg_size); mir_free(pi.szMsg); } } else lstrcpyn(msg, "", msg_size); if (ServiceExists(MS_VARS_FORMATSTRING)) { char *tmp = variables_parse(msg, NULL, NULL); lstrcpyn(msg, tmp, msg_size); variables_free(tmp); } } // TODO: Remove when removing old NAS services support else if (ServiceExists("NewAwaySystem/GetState")) { NAS_PROTOINFO pi, *pii; ZeroMemory(&pi, sizeof(pi)); pi.cbSize = sizeof(NAS_PROTOINFO); pi.szProto = (char *) name.c_str(); pi.status = (isCurrentStatus ? 0 : aStatus); pi.szMsg = NULL; pii = π if (CallService("NewAwaySystem/GetState", (WPARAM) &pii, 1) == 0) { if (pi.szMsg == NULL) { pi.szProto = NULL; if (CallService("NewAwaySystem/GetState", (WPARAM) &pii, 1) == 0) { if (pi.szMsg != NULL) { lstrcpyn(msg, pi.szMsg, msg_size); mir_free(pi.szMsg); } else lstrcpyn(msg, "", msg_size); } else lstrcpyn(msg, "", msg_size); } else // if (pi.szMsg != NULL) { lstrcpyn(msg, pi.szMsg, msg_size); mir_free(pi.szMsg); } } else lstrcpyn(msg, "", msg_size); if (ServiceExists(MS_VARS_FORMATSTRING)) { char *tmp = variables_parse(msg, NULL, NULL); lstrcpyn(msg, tmp, msg_size); variables_free(tmp); } } else if (ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) { char *tmp = (char *) CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)aStatus, 0); if (tmp != NULL) { lstrcpyn(msg, tmp, msg_size); mir_free(tmp); } else lstrcpyn(msg, "", msg_size); } }
// load the station data from a file // pszFile = the file name + path for the ini file to be loaded // pszShortFile = the file name of the ini file, but not including the path // Data = the struct to load the ini content to, and return to previous function void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data) { WIDATAITEM DataItem; char *Group, *Temp; char *ValName, *Value; static const char *statusStr[10] = { "LIGHTNING", "FOG", "SNOW SHOWER", "SNOW", "RAIN SHOWER", "RAIN", "PARTLY CLOUDY", "CLOUDY", "SUNNY", "N/A" }; // clean up old stuff ZeroMemory(Data, sizeof(Data)); Data->Enabled = FALSE; // open the ini file FILE *pfile = _tfsopen(pszFile, _T("rt"), _SH_DENYWR); if (pfile != NULL) { char Line[4096]; fgets(Line, SIZEOF(Line), pfile); TrimString(Line); // make sure it is a valid weather protocol ini file if ( !strcmp(Line, "[Weather 0.3.x Update Data]")) Data->InternalVer = 1; else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.1]")) Data->InternalVer = 2; else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.1a]")) Data->InternalVer = 3; else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.2]")) Data->InternalVer = 4; else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.3]")) Data->InternalVer = 5; else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.4]")) Data->InternalVer = 6; else { TCHAR str[4096]; mir_sntprintf(str, SIZEOF(str), TranslateT("Invalid ini format for: %s"), pszFile); MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONERROR); fclose(pfile); return; } // initialize all data fields Group = ""; Data->DisplayName = _T(""); Data->InternalName = _T(""); Data->Description = _T(""); Data->Author = _T(""); Data->Version = _T(""); Data->DefaultURL = ""; Data->DefaultMap = _T(""); Data->UpdateURL = ""; Data->UpdateURL2 = ""; Data->UpdateURL3 = ""; Data->UpdateURL4 = ""; Data->Cookie = ""; Data->IDSearch.SearchURL = ""; Data->IDSearch.NotFoundStr = _T(""); Data->NameSearch.SearchURL = ""; Data->NameSearch.NotFoundStr = _T(""); Data->NameSearch.SingleStr = _T(""); Data->NameSearch.Single.First = _T(""); Data->NameSearch.Multiple.First = _T(""); Data->IDSearch.Available = FALSE; Data->NameSearch.Single.Available = FALSE; Data->NameSearch.Multiple.Available = FALSE; wSetData(&Data->FileName, pszFile); wSetData(&Data->ShortFileName, pszShortFile); ResetDataItem(&Data->IDSearch.Name, _T("ID Search - Station Name")); ResetDataItem(&Data->NameSearch.Single.Name, _T("Name Search Single Result - Station Name")); ResetDataItem(&Data->NameSearch.Single.ID, _T("Name Search Single Result - Station ID")); ResetDataItem(&Data->NameSearch.Multiple.Name, _T("Name Search Multiple Result - Station Name")); ResetDataItem(&Data->NameSearch.Multiple.ID, _T("Name Search Multiple Result - Station ID")); DataItem.Name = _T(""); DataItem.Start = _T(""); DataItem.End = _T(""); DataItem.Unit = _T(""); DataItem.Url = ""; DataItem.Break = _T(""); DataItem.Type = 0; Temp = ""; // initialize the linked list for update items Data->UpdateDataCount = 0; Data->MemUsed = sizeof(WIDATA) + sizeof(WIDATALIST) + (_tcslen(pszShortFile) + _tcslen(pszFile) + 20)*sizeof( TCHAR ); Data->UpdateData = NULL; Data->UpdateDataTail = NULL; // initialize the icon assignment list for (int i=0; i<10; i++) WICondListInit( &Data->CondList[i] ); while (!feof(pfile)) { // determine current tag if (fgets(Line, SIZEOF(Line), pfile) == NULL) break; TrimString(Line); // if the line is a group header/footer if (Line[0] == '[') { char *chop = strchr(Line+1,']'); if (chop == NULL) continue; if (Line[1] != '/') { // if it is not a footer (for old ini) // save the group name Temp = (char *)mir_alloc(strlen(Line)+10); strncpy(Temp, Line+1, chop-Line-1); Temp[chop-Line-1] = 0; wfree(&Group); wSetData(&Group, Temp); // see if it is a update item, if it is, add a new item to the linked list // if (_stricmp(Group, "HEADER") && _stricmp(Group, "DEFAULT") && _stricmp(Group, "ID SEARCH") && // strcmpi(Group, "NAME SEARCH")) // wSetData(&DataItem.Name, Group); if (_stricmp(Group, "HEADER") && _stricmp(Group, "DEFAULT") && _stricmp(Group, "ID SEARCH") && _stricmp(Group, "NAME SEARCH") && _stricmp(Group, "ICONS")) { wSetData(&DataItem.Name, Temp); DataItem.Type = WID_NORMAL; WIItemListAdd(&DataItem, Data); Data->UpdateDataCount++; } mir_free(Temp); } else { wfree(&Group); wSetData(&Group, ""); } } // ignore comments and all lines without an '=' Value = strstr(Line, "="); if (Value == NULL) continue; // get the string before '=' (ValName) and after '=' (Value) ValName = (char *)mir_alloc(strlen(Line)+1); strncpy(ValName, Line, Value-Line); ValName[Value-Line] = 0; Value++; ConvertBackslashes(Value); // store the value for each string if ( !_stricmp(Group, "HEADER")) { if ( !_stricmp(ValName, "NAME")) wSetData(&Data->DisplayName, Value); else if ( !_stricmp(ValName, "INTERNAL NAME")) wSetData(&Data->InternalName, Value); else if ( !_stricmp(ValName, "DESCRIPTION")) wSetData(&Data->Description, Value); else if ( !_stricmp(ValName, "AUTHOR")) wSetData(&Data->Author, Value); else if ( !_stricmp(ValName, "VERSION")) wSetData(&Data->Version, Value); } else if ( !_stricmp(Group, "DEFAULT")) { if ( !_stricmp(ValName, "DEFAULT URL")) wSetData(&Data->DefaultURL, Value); else if ( !_stricmp(ValName, "DEFAULT MAP")) wSetData(&Data->DefaultMap, Value); else if ( !_stricmp(ValName, "UPDATE URL")) wSetData(&Data->UpdateURL, Value); else if ( !_stricmp(ValName, "UPDATE URL2")) wSetData(&Data->UpdateURL2, Value); else if ( !_stricmp(ValName, "UPDATE URL3")) wSetData(&Data->UpdateURL3, Value); else if ( !_stricmp(ValName, "UPDATE URL4")) wSetData(&Data->UpdateURL4, Value); else if ( !_stricmp(ValName, "COOKIE")) wSetData(&Data->Cookie, Value); } else if ( !_stricmp(Group, "ID SEARCH")) { if ( !_stricmp(ValName, "AVAILABLE")) { if ( !_stricmp(Value, "TRUE")) Data->IDSearch.Available = TRUE; else Data->IDSearch.Available = FALSE; } else if ( !_stricmp(ValName, "SEARCH URL")) wSetData(&Data->IDSearch.SearchURL, Value); else if ( !_stricmp(ValName, "NOT FOUND STR")) wSetData(&Data->IDSearch.NotFoundStr, Value); else if ( !_stricmp(ValName, "NAME START")) wSetData(&Data->IDSearch.Name.Start, Value); else if ( !_stricmp(ValName, "NAME END")) wSetData(&Data->IDSearch.Name.End, Value); } else if ( !_stricmp(Group, "NAME SEARCH")) { if ( !_stricmp(ValName, "SINGLE RESULT")) { if ( !_stricmp(Value, "TRUE")) Data->NameSearch.Single.Available = TRUE; else Data->NameSearch.Single.Available = FALSE; } else if ( !_stricmp(ValName, "MULTIPLE RESULT")) { if ( !_stricmp(Value, "TRUE")) Data->NameSearch.Multiple.Available = TRUE; else Data->NameSearch.Multiple.Available = FALSE; } else if ( !_stricmp(ValName, "SEARCH URL")) wSetData(&Data->NameSearch.SearchURL, Value); else if ( !_stricmp(ValName, "NOT FOUND STR")) wSetData(&Data->NameSearch.NotFoundStr, Value); else if ( !_stricmp(ValName, "SINGLE RESULT STR")) wSetData(&Data->NameSearch.SingleStr, Value); else if ( !_stricmp(ValName, "SINGLE FIRST")) wSetData(&Data->NameSearch.Single.First, Value); else if ( !_stricmp(ValName, "SINGLE NAME START"))wSetData(&Data->NameSearch.Single.Name.Start, Value); else if ( !_stricmp(ValName, "SINGLE NAME END")) wSetData(&Data->NameSearch.Single.Name.End, Value); else if ( !_stricmp(ValName, "SINGLE ID START")) wSetData(&Data->NameSearch.Single.ID.Start, Value); else if ( !_stricmp(ValName, "SINGLE ID END")) wSetData(&Data->NameSearch.Single.ID.End, Value); else if ( !_stricmp(ValName, "MULT FIRST")) wSetData(&Data->NameSearch.Multiple.First, Value); else if ( !_stricmp(ValName, "MULT NAME START")) wSetData(&Data->NameSearch.Multiple.Name.Start, Value); else if ( !_stricmp(ValName, "MULT NAME END")) wSetData(&Data->NameSearch.Multiple.Name.End, Value); else if ( !_stricmp(ValName, "MULT ID START")) wSetData(&Data->NameSearch.Multiple.ID.Start, Value); else if ( !_stricmp(ValName, "MULT ID END")) wSetData(&Data->NameSearch.Multiple.ID.End, Value); } else if ( !_stricmp(Group, "ICONS")) { for (int i=0; i<10; i++) { if ( !_stricmp(ValName, statusStr[i])) { WICondListAdd(Value, &Data->CondList[i]); break; } } } else if (Data->UpdateDataCount != 0) { if ( !_stricmp(ValName, "START")) wSetData(&Data->UpdateDataTail->Item.Start, Value); else if ( !_stricmp(ValName, "SOURCE")) wSetData(&Data->UpdateDataTail->Item.Start, Value); else if ( !_stricmp(ValName, "END")) wSetData(&Data->UpdateDataTail->Item.End, Value); else if ( !_stricmp(ValName, "UNIT")) wSetData(&Data->UpdateDataTail->Item.Unit, Value); else if ( !_stricmp(ValName, "URL")) wSetData(&Data->UpdateDataTail->Item.Url, Value); else if ( !_stricmp(ValName, "HIDDEN")) { if ( !_stricmp(Value, "TRUE")) { TCHAR *nm = Data->UpdateDataTail->Item.Name; size_t len = _tcslen(nm) + 1; Data->UpdateDataTail->Item.Name = nm = ( TCHAR* )mir_realloc(nm, sizeof(TCHAR)*(len + 3)); memmove(nm + 1, nm, len*sizeof( TCHAR )); *nm = '#'; } } else if ( !_stricmp(ValName, "SET DATA")) { Data->UpdateDataTail->Item.Type = WID_SET; wSetData(&Data->UpdateDataTail->Item.End, Value); } else if ( !_stricmp(ValName, "BREAK DATA")) { Data->UpdateDataTail->Item.Type = WID_BREAK; wSetData(&Data->UpdateDataTail->Item.Break, Value); } } // recalculate memory used Data->MemUsed += (strlen(Value) + 10); wfree(&ValName); } // calcualate memory used for the ini and close the file Data->MemUsed += sizeof(WIDATAITEMLIST)*Data->UpdateDataCount; Data->Enabled = TRUE; // enable the service fclose(pfile); wfree(&Group); } }
static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule, char *szSetting, int special, int disableIfUndef) { DBVARIANT dbv = {0}; TCHAR str[256]; TCHAR *ptstr = NULL; TCHAR* valT = NULL; int unspecified = 0; dbv.type = DBVT_DELETED; if (szModule == NULL) unspecified = 1; else unspecified = db_get(hContact, szModule, szSetting, &dbv); if (!unspecified) { switch (dbv.type) { case DBVT_BYTE: if (special == SVS_GENDER) { if (dbv.cVal == 'M') ptstr = TranslateT("Male"); else if (dbv.cVal == 'F') ptstr = TranslateT("Female"); else unspecified = 1; } else if (special == SVS_MONTH) { if (dbv.bVal > 0 && dbv.bVal <= 12) { ptstr = str; GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1 - 1 + dbv.bVal, str, _countof(str)); } else unspecified = 1; } else if (special == SVS_TIMEZONE) { if (dbv.cVal == -100) unspecified = 1; else { ptstr = str; mir_sntprintf(str, _countof(str), dbv.cVal ? _T("GMT%+d:%02d") : _T("GMT"), -dbv.cVal / 2, (dbv.cVal & 1) * 30); } } else { unspecified = (special == SVS_ZEROISUNSPEC && dbv.bVal == 0); ptstr = _itot(special == SVS_SIGNED ? dbv.cVal : dbv.bVal, str, 10); } break; case DBVT_WORD: if (special == SVS_COUNTRY) { char* pstr = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, dbv.wVal, 0); if (pstr == NULL){ unspecified = 1; } else { ptstr = str; mir_sntprintf(str, _countof(str), _T("%S"), pstr); } } else { unspecified = (special == SVS_ZEROISUNSPEC && dbv.wVal == 0); ptstr = _itot(special == SVS_SIGNED ? dbv.sVal : dbv.wVal, str, 10); } break; case DBVT_DWORD: unspecified = (special == SVS_ZEROISUNSPEC && dbv.dVal == 0); if (special == SVS_IP) { struct in_addr ia; ia.S_un.S_addr = htonl(dbv.dVal); char* pstr = inet_ntoa(ia); if (pstr == NULL){ unspecified = 1; } else { ptstr = str; mir_sntprintf(str, _countof(str), _T("%S"), pstr); } if (dbv.dVal == 0) unspecified = 1; } else if (special == SVS_GGVERSION) { ptstr = str; mir_sntprintf(str, _countof(str), _T("%S"), (char *)gg_version2string(dbv.dVal)); } else { ptstr = _itot(special == SVS_SIGNED ? dbv.lVal : dbv.dVal, str, 10); } break; case DBVT_ASCIIZ: unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); ptstr = str; mir_sntprintf(str, _countof(str), _T("%S"), dbv.pszVal); break; case DBVT_TCHAR: unspecified = (special == SVS_ZEROISUNSPEC && dbv.ptszVal[0] == '\0'); ptstr = dbv.ptszVal; break; case DBVT_UTF8: unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); valT = mir_utf8decodeT(dbv.pszVal); ptstr = str; _tcscpy_s(str, _countof(str), valT); mir_free(valT); break; default: ptstr = str; mir_tstrcpy(str, _T("???")); break; } } if (disableIfUndef) { EnableWindow(GetDlgItem(hwndDlg, idCtrl), !unspecified); if (unspecified) SetDlgItemText(hwndDlg, idCtrl, TranslateT("<not specified>")); else SetDlgItemText(hwndDlg, idCtrl, ptstr); } else { EnableWindow(GetDlgItem(hwndDlg, idCtrl), TRUE); if (!unspecified) SetDlgItemText(hwndDlg, idCtrl, ptstr); } db_free(&dbv); }
TLV::~TLV() { mir_free(value_); }
int __fastcall CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, struct ClcData *dat) { int dbHidden = cfg::getByte(hContact, "CList", "Hidden", 0); // default hidden state, always respect it. int filterResult = 1; DBVARIANT dbv = {0}; char szTemp[64]; wchar_t szGroupMask[256]; DWORD dwLocalMask; // always hide subcontacts (but show them on embedded contact lists) if(cfg::dat.bMetaAvail && dat != NULL && dat->bHideSubcontacts && cfg::dat.bMetaEnabled && cfg::getByte(hContact, cfg::dat.szMetaName, "IsSubcontact", 0)) return 1; if(cfg::dat.bFilterEffective) { if (szProto == NULL) szProto = GetContactProto(hContact); // check stickies first (priority), only if we really have stickies defined (CLVM_STICKY_CONTACTS is set). if(cfg::dat.bFilterEffective & CLVM_STICKY_CONTACTS) { if((dwLocalMask = cfg::getDword(hContact, "CLVM", cfg::dat.current_viewmode, 0)) != 0) { if(cfg::dat.bFilterEffective & CLVM_FILTER_STICKYSTATUS) { WORD wStatus = cfg::getWord(hContact, szProto, "Status", ID_STATUS_OFFLINE); return !((1 << (wStatus - ID_STATUS_OFFLINE)) & HIWORD(dwLocalMask)); } return 0; } } // check the proto, use it as a base filter result for all further checks if(cfg::dat.bFilterEffective & CLVM_FILTER_PROTOS) { mir_snprintf(szTemp, sizeof(szTemp), "%s|", szProto); filterResult = strstr(cfg::dat.protoFilter, szTemp) ? 1 : 0; } if(cfg::dat.bFilterEffective & CLVM_FILTER_GROUPS) { if(!cfg::getTString(hContact, "CList", "Group", &dbv)) { _sntprintf(szGroupMask, safe_sizeof(szGroupMask), _T("%s|"), &dbv.ptszVal[1]); filterResult = (cfg::dat.filterFlags & CLVM_PROTOGROUP_OP) ? (filterResult | (_tcsstr(cfg::dat.groupFilter, szGroupMask) ? 1 : 0)) : (filterResult & (_tcsstr(cfg::dat.groupFilter, szGroupMask) ? 1 : 0)); mir_free(dbv.ptszVal); } else if(cfg::dat.filterFlags & CLVM_INCLUDED_UNGROUPED) filterResult = (cfg::dat.filterFlags & CLVM_PROTOGROUP_OP) ? filterResult : filterResult & 1; else filterResult = (cfg::dat.filterFlags & CLVM_PROTOGROUP_OP) ? filterResult : filterResult & 0; } if(cfg::dat.bFilterEffective & CLVM_FILTER_STATUS) { WORD wStatus = cfg::getWord(hContact, szProto, "Status", ID_STATUS_OFFLINE); filterResult = (cfg::dat.filterFlags & CLVM_GROUPSTATUS_OP) ? ((filterResult | ((1 << (wStatus - ID_STATUS_OFFLINE)) & cfg::dat.statusMaskFilter ? 1 : 0))) : (filterResult & ((1 << (wStatus - ID_STATUS_OFFLINE)) & cfg::dat.statusMaskFilter ? 1 : 0)); } if(cfg::dat.bFilterEffective & CLVM_FILTER_LASTMSG) { DWORD now; int iEntry = cfg::getCache(hContact, szProto); if(iEntry >= 0 && iEntry <= cfg::nextCacheEntry) { now = cfg::dat.t_now; now -= cfg::dat.lastMsgFilter; if(cfg::dat.bFilterEffective & CLVM_FILTER_LASTMSG_OLDERTHAN) filterResult = filterResult & (cfg::eCache[iEntry].dwLastMsgTime < now); else if(cfg::dat.bFilterEffective & CLVM_FILTER_LASTMSG_NEWERTHAN) filterResult = filterResult & (cfg::eCache[iEntry].dwLastMsgTime > now); } } return (dbHidden | !filterResult); } else return dbHidden; }
static int InputMenuPopup(WPARAM, LPARAM lParam) { HMENU hSubMenu = NULL; int i = 0; MessageWindowPopupData * mwpd = (MessageWindowPopupData *)lParam; if (mwpd->uFlags == MSG_WINDOWPOPUP_LOG || !g_bQuickMenu || !QuickList->realCount) return 0; if (mwpd->uType == MSG_WINDOWPOPUP_SHOWING) { hSubMenu = CreatePopupMenu(); InsertMenu((HMENU)mwpd->hMenu, 6, MF_STRING | MF_POPUP | MF_BYPOSITION, (UINT_PTR)hSubMenu, TranslateT("Quick Messages")); InsertMenu((HMENU)mwpd->hMenu, 7, MF_SEPARATOR | MF_BYPOSITION, 0, 0); qsort(QuickList->items, QuickList->realCount, sizeof(QuickData *), sstQuickSortButtons); for (i = 0; i < QuickList->realCount; i++) { QuickData* qd = (QuickData *)QuickList->items[i]; if (qd->fEntryType&QMF_EX_SEPARATOR) AppendMenu(hSubMenu, MF_SEPARATOR, 0, NULL); else AppendMenu(hSubMenu, MF_STRING, qd->dwPos + 254, qd->ptszValueName); } } else if (mwpd->uType == MSG_WINDOWPOPUP_SELECTED&&mwpd->selection >= 254) { for (i = 0; i < QuickList->realCount; i++) { QuickData* qd = (QuickData *)QuickList->items[i]; if ((qd->dwPos + 254) == mwpd->selection) { CHARRANGE cr; UINT textlenght = 0; TCHAR* pszText = NULL; TCHAR* ptszQValue = NULL; TCHAR* pszCBText = NULL; BOOL bIsService = 0; if (IsClipboardFormatAvailable(CF_TEXT)) { if (OpenClipboard(mwpd->hwnd)) { HANDLE hData = NULL; TCHAR* chBuffer = NULL; int textLength = 0; hData = GetClipboardData(CF_UNICODETEXT); chBuffer = (TCHAR*)GlobalLock(hData); textLength = (int)mir_tstrlen(chBuffer); pszCBText = mir_tstrdup(chBuffer); GlobalUnlock(hData); CloseClipboard(); } } SendMessage(mwpd->hwnd, EM_EXGETSEL, 0, (LPARAM)&cr); textlenght = cr.cpMax - cr.cpMin; if (textlenght) { pszText = (TCHAR *)mir_alloc((textlenght + 10)*sizeof(TCHAR)); memset(pszText, 0, ((textlenght + 10) * sizeof(TCHAR))); SendMessage(mwpd->hwnd, EM_GETSELTEXT, 0, (LPARAM)pszText); } if (qd->ptszValue) { ptszQValue = ParseString(mwpd->hContact, qd->ptszValue, pszText ? pszText : _T(""), pszCBText ? pszCBText : _T(""), (int)mir_tstrlen(qd->ptszValue), textlenght, pszCBText ? (int)mir_tstrlen(pszCBText) : 0); if ((bIsService = qd->bIsService) && ptszQValue) CallService(mir_u2a(ptszQValue), (WPARAM)mwpd->hContact, 0); } if (ptszQValue) SendMessage(mwpd->hwnd, EM_REPLACESEL, TRUE, (LPARAM)ptszQValue); if (pszText) mir_free(pszText); if (ptszQValue) free(ptszQValue); if (pszCBText) mir_free(pszCBText); break; } } return 1; } return 0; }
SERVER_INFO::~SERVER_INFO() { mir_free( m_name ); mir_free( m_address ); mir_free( m_group ); }
//see Q160957 and http://developer.netscape.com/docs/manuals/communicator/DDE/index.htm static void GetOpenBrowserUrlsForBrowser(const char *szBrowser, HWND hwndDlg, HWND hwndCombo) { ATOM hSzBrowser, hSzTopic; int windowCount, i; DWORD *windowId; DWORD dwResult; HGLOBAL hData; DDEDATA *data; int dataLength; hSzBrowser = GlobalAddAtomA(szBrowser); hSzTopic = GlobalAddAtomA("WWW_ListWindows"); ddeAcked = 0; if ( !SendMessageTimeout(HWND_BROADCAST, WM_DDE_INITIATE, (WPARAM)hwndDlg, MAKELPARAM(hSzBrowser, hSzTopic), SMTO_ABORTIFHUNG|SMTO_NORMAL, DDEMESSAGETIMEOUT, (PDWORD_PTR)&dwResult) || !ddeAcked) { GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); return; } hData = DoDdeRequest("WWW_ListWindows", hwndDlg); if (hData == NULL) { GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); return; } dataLength = GlobalSize(hData)-offsetof(DDEDATA, Value); data = (DDEDATA*)GlobalLock(hData); windowCount = dataLength/sizeof(DWORD); windowId = (PDWORD)mir_alloc(sizeof(DWORD)*windowCount); memcpy(windowId, data->Value, windowCount*sizeof(DWORD)); GlobalUnlock(hData); FreeDdeRequestData(hData); PostMessage(hwndDde, WM_DDE_TERMINATE, (WPARAM)hwndDlg, 0); GlobalDeleteAtom(hSzTopic); hSzTopic = GlobalAddAtomA("WWW_GetWindowInfo"); ddeAcked = 0; if ( !SendMessageTimeout(HWND_BROADCAST, WM_DDE_INITIATE, (WPARAM)hwndDlg, MAKELPARAM(hSzBrowser, hSzTopic), SMTO_ABORTIFHUNG|SMTO_NORMAL, DDEMESSAGETIMEOUT, (PDWORD_PTR)&dwResult) || !ddeAcked) { GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); mir_free(windowId); return; } for (i=0;i<windowCount;i++) { if (windowId[i] == 0) break; { char str[16]; mir_snprintf(str, SIZEOF(str), "%d", windowId[i]); hData = DoDdeRequest(str, hwndDlg); } if (hData != NULL) { dataLength = GlobalSize(hData)-offsetof(DDEDATA, Value); data = (DDEDATA*)GlobalLock(hData); AddBrowserPageToCombo((char*)data->Value, hwndCombo); GlobalUnlock(hData); FreeDdeRequestData(hData); } } PostMessage(hwndDde, WM_DDE_TERMINATE, (WPARAM)hwndDlg, 0); GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); mir_free(windowId); }
INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct UrlSendData* dat = (struct UrlSendData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_URL); 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")); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_LIMITTEXT, 450, 0); dat = (struct UrlSendData*)mir_alloc(sizeof(struct UrlSendData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = lParam; dat->hAckEvent = NULL; dat->hSendId = NULL; dat->sendBuffer = NULL; WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact); { TCHAR *str = pcli->pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_NAME, str); } GetOpenBrowserUrls(hwndDlg, GetDlgItem(hwndDlg, IDC_URLS)); SendDlgItemMessage(hwndDlg, IDC_URLS, CB_SETCURSEL, 0, 0); if (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0))SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_URLS, CBN_SELCHANGE), 0); EnableWindow(GetDlgItem(hwndDlg, IDOK), (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0) == CB_ERR)?FALSE:TRUE); Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "send"); mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MESSAGE), SendEditSubclassProc); mir_subclassWindow( GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), SendEditSubclassProc); // From message dlg if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0); // From message dlg end return TRUE; case WM_DDE_DATA: case WM_DDE_ACK: return DdeMessage(hwndDlg, msg, wParam, lParam); case WM_TIMER: if (wParam == 0) { //ICQ sendurl timed out KillTimer(hwndDlg, 0); MessageBox(hwndDlg, TranslateT("Send timed out"), _T(""), MB_OK); EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), TRUE); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, FALSE, 0); } break; 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 DM_UPDATETITLE: sttUpdateTitle(hwndDlg, dat->hContact); break; case WM_COMMAND: if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch (LOWORD(wParam)) { case IDOK: { char *body, *url; int bodySize, urlSize; urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS))+1; url = (char*)mir_alloc(urlSize); GetDlgItemTextA(hwndDlg, IDC_URLS, url, urlSize); if (url[0] == 0) { mir_free(url); break; } bodySize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE))+1; body = (char*)mir_alloc(bodySize); GetDlgItemTextA(hwndDlg, IDC_MESSAGE, body, bodySize); dat->sendBuffer = (char*)mir_realloc(dat->sendBuffer, lstrlenA(url)+lstrlenA(body)+2); lstrcpyA(dat->sendBuffer, url); lstrcpyA(dat->sendBuffer+lstrlenA(url)+1, body); dat->hAckEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT); dat->hSendId = (HANDLE)CallContactService(dat->hContact, PSS_URL, 0, (LPARAM)dat->sendBuffer); mir_free(url); mir_free(body); //create a timeout timer SetTimer(hwndDlg, 0, TIMEOUT_URLSEND, NULL); EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), FALSE); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, TRUE, 0); return TRUE; } case IDCANCEL: DestroyWindow(hwndDlg); return TRUE; case IDC_URLS: if (HIWORD(wParam) == CBN_SELCHANGE) { int i, urlSize; char *title; i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0); title = (char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, (WPARAM)i, 0); SetDlgItemTextA(hwndDlg, IDC_MESSAGE, title); urlSize = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETLBTEXTLEN, (WPARAM)i, 0); EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0)); } else if (HIWORD(wParam) == CBN_EDITCHANGE) { int urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS)); EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0)); } break; case IDC_USERMENU: { RECT rc; HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_ADD: ADDCONTACTSTRUCT acs = {0}; acs.hContact = dat->hContact; acs.handleType = HANDLE_CONTACT; acs.szProto = 0; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); } break; case HM_EVENTSENT: { ACKDATA *ack = (ACKDATA*)lParam; if (ack->hProcess != dat->hSendId) break; if (ack->hContact != dat->hContact) break; if (ack->type != ACKTYPE_URL || ack->result != ACKRESULT_SUCCESS) break; DBEVENTINFO dbei = { sizeof(dbei) }; dbei.eventType = EVENTTYPE_URL; dbei.flags = DBEF_SENT; dbei.szModule = GetContactProto(dat->hContact); dbei.timestamp = time(NULL); dbei.cbBlob = (DWORD)(strlen(dat->sendBuffer)+strlen(dat->sendBuffer+strlen(dat->sendBuffer)+1)+2); dbei.pBlob = (PBYTE)dat->sendBuffer; db_event_add(dat->hContact, &dbei); KillTimer(hwndDlg, 0); DestroyWindow(hwndDlg); } 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); WindowList_Remove(hUrlWindowList, hwndDlg); if (dat->hAckEvent) UnhookEvent(dat->hAckEvent); if (dat->sendBuffer != NULL) mir_free(dat->sendBuffer); mir_free(dat); Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "send"); for (int i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0)-1;i>=0;i--) mir_free((char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, i, 0)); break; } return FALSE; }
static bool NetlibHttpGatewaySend(struct NetlibConnection *nlc, RequestType reqType, const char *buf, int len) { NETLIBHTTPREQUEST nlhrSend = {0}; char szUrl[512]; nlhrSend.cbSize = sizeof(nlhrSend); nlhrSend.nlc = nlc; nlhrSend.pData = (char*)buf; nlhrSend.dataLength = len; nlhrSend.flags = NLHRF_GENERATEHOST | NLHRF_DUMPPROXY | NLHRF_SMARTAUTHHEADER | NLHRF_NOPROXY | NLHRF_REDIRECT; if (nlc->nlhpi.flags & NLHPIF_HTTP11) nlhrSend.flags |= NLHRF_HTTP11; switch (reqType) { case reqHelloGet: nlhrSend.requestType = REQUEST_GET; nlhrSend.szUrl=nlc->nlu->user.szHttpGatewayHello; break; case reqOldGet: nlhrSend.requestType = REQUEST_GET; nlhrSend.timeout = -1; if ((nlc->nlhpi.flags & NLHPIF_USEGETSEQUENCE) && (nlc->nlhpi.szHttpGetUrl != NULL)) { EnterCriticalSection(&nlc->csHttpSequenceNums); mir_snprintf(szUrl, SIZEOF(szUrl), "%s%u", nlc->nlhpi.szHttpGetUrl, nlc->nlhpi.firstGetSequence++); if (nlc->nlhpi.flags & NLHPIF_GETPOSTSAMESEQUENCE) nlc->nlhpi.firstPostSequence++; LeaveCriticalSection(&nlc->csHttpSequenceNums); nlhrSend.szUrl = szUrl; } else nlhrSend.szUrl = nlc->nlhpi.szHttpGetUrl; break; case reqOldPost: nlhrSend.requestType = REQUEST_POST; if ((nlc->nlhpi.flags & NLHPIF_USEPOSTSEQUENCE) && (nlc->nlhpi.szHttpPostUrl != NULL)) { mir_snprintf(szUrl, SIZEOF(szUrl), "%s%u", nlc->nlhpi.szHttpPostUrl, nlc->nlhpi.firstPostSequence); nlhrSend.szUrl = szUrl; } else nlhrSend.szUrl = nlc->nlhpi.szHttpPostUrl; break; case reqNewPost: nlhrSend.requestType = REQUEST_POST; nlhrSend.szUrl = nlc->nlhpi.szHttpPostUrl; break; } if (nlc->usingDirectHttpGateway) { NETLIBOPENCONNECTION nloc; NetlibConnFromUrl(nlhrSend.szUrl, false, nloc); bool sameHost = lstrcmpA(nlc->nloc.szHost, nloc.szHost) == 0 && nlc->nloc.wPort == nloc.wPort; if (!sameHost) { NetlibDoClose(nlc); mir_free((char*)nlc->nloc.szHost); nlc->nloc = nloc; if (!NetlibDoConnect(nlc)) return false; } else mir_free((char*)nloc.szHost); } nlhrSend.headersCount = 3; nlhrSend.headers = (NETLIBHTTPHEADER*)alloca(sizeof(NETLIBHTTPHEADER) * nlhrSend.headersCount); nlhrSend.headers[0].szName = "User-Agent"; nlhrSend.headers[0].szValue = nlc->nlu->user.szHttpGatewayUserAgent; nlhrSend.headers[1].szName = "Cache-Control"; nlhrSend.headers[1].szValue = "no-cache, no-store "; nlhrSend.headers[2].szName = "Pragma"; nlhrSend.headers[2].szValue = "no-cache"; // nlhrSend.headers[3].szName = "Accept-Encoding"; // nlhrSend.headers[3].szValue = "deflate, gzip"; return NetlibHttpSendRequest((WPARAM)nlc,(LPARAM)&nlhrSend) != SOCKET_ERROR; }
void __cdecl SplashThread(void *arg) { IGraphBuilder *pGraph = NULL; IMediaControl *pControl = NULL; if (options.playsnd) { // Initialize the COM library. CoInitialize(NULL); // Create the filter graph manager and query for interfaces. CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph); // Get MediaControl Interface pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl); // Build the graph. IMPORTANT: Change this string to a file on your system. pGraph->RenderFile(szSoundFile, NULL); // Run the graph. pControl->Run(); } WNDCLASSEX wcl; wcl.cbSize = sizeof(wcl); wcl.lpfnWndProc = SplashWindowProc; wcl.style = 0; wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; wcl.hInstance = hInst; wcl.hIcon = NULL; wcl.hCursor = LoadCursor(NULL, IDC_ARROW); wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); wcl.lpszMenuName = NULL; wcl.lpszClassName = _T(SPLASH_CLASS); wcl.hIconSm = NULL; RegisterClassEx(&wcl); RECT DesktopRect; int w = GetSystemMetrics(SM_CXSCREEN); int h = GetSystemMetrics(SM_CYSCREEN); DesktopRect.left = 0; DesktopRect.top = 0; DesktopRect.right = w; DesktopRect.bottom = h; RECT WindowRect; WindowRect.left = (DesktopRect.left + DesktopRect.right - SplashBmp->getWidth()) / 2; WindowRect.top = (DesktopRect.top + DesktopRect.bottom - SplashBmp->getHeight()) / 2; WindowRect.right = WindowRect.left + SplashBmp->getWidth(); WindowRect.bottom = WindowRect.top + SplashBmp->getHeight(); hwndSplash = CreateWindowEx( WS_EX_TOOLWINDOW | WS_EX_TOPMOST,//dwStyleEx _T(SPLASH_CLASS), //Class name NULL, //Title DS_SETFONT | DS_FIXEDSYS | WS_POPUP, //dwStyle WindowRect.left, // x WindowRect.top, // y SplashBmp->getWidth(), // Width SplashBmp->getHeight(), // Height HWND_DESKTOP, //Parent NULL, //menu handle hInst, //Instance NULL); RECT rc; GetWindowRect(hwndSplash, &rc); POINT ptDst = { rc.left, rc.top }; POINT ptSrc = { 0, 0 }; SIZE sz = { rc.right - rc.left, rc.bottom - rc.top }; bool splashWithMarkers = false; BLENDFUNCTION blend; blend.BlendOp = AC_SRC_OVER; blend.BlendFlags = 0; blend.SourceConstantAlpha = 0; blend.AlphaFormat = AC_SRC_ALPHA; if (options.showversion) { // locate text markers: int i, x = -1, y = -1; int splashWidth = SplashBmp->getWidth(); for (i = 0; i < splashWidth; ++i) if (SplashBmp->getRow(0)[i] & 0xFF000000) { if (x < 0) { x = i - 1; // 1 pixel for marker line splashWithMarkers = true; } else { x = -1; splashWithMarkers = false; break; } } int splashHeight = SplashBmp->getHeight(); for (i = 0; splashWithMarkers && (i < splashHeight); ++i) if (SplashBmp->getRow(i)[0] & 0xFF000000) { if (y < 0) { y = i - 1; // 1 pixel for marker line splashWithMarkers = true; } else { y = -1; splashWithMarkers = false; break; } } TCHAR verString[256] = { 0 }; TCHAR *mirandaVerString = mir_a2t(szVersion); mir_sntprintf(verString, _T("%s%s"), szPrefix, mirandaVerString); mir_free(mirandaVerString); LOGFONT lf = { 0 }; lf.lfHeight = 14; mir_tstrcpy(lf.lfFaceName, _T("Verdana")); SelectObject(SplashBmp->getDC(), CreateFontIndirect(&lf)); if (!splashWithMarkers) { SIZE v_sz = { 0, 0 }; GetTextExtentPoint32(SplashBmp->getDC(), verString, (int)mir_tstrlen(verString), &v_sz); x = SplashBmp->getWidth() / 2 - (v_sz.cx / 2); y = SplashBmp->getHeight() - (SplashBmp->getHeight()*(100 - 90) / 100); } SetTextColor(SplashBmp->getDC(), (0xFFFFFFFFUL - SplashBmp->getRow(y)[x]) & 0x00FFFFFFUL); SetBkMode(SplashBmp->getDC(), TRANSPARENT); SplashBmp->DrawText(verString, x, y); } SetWindowLongPtr(hwndSplash, GWL_EXSTYLE, GetWindowLongPtr(hwndSplash, GWL_EXSTYLE) | WS_EX_LAYERED); UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); ShowWindow(hwndSplash, SW_SHOWNORMAL); if (options.fadein) { // Fade in for (int i = 0; i < 255; i += options.fisteps) { blend.SourceConstantAlpha = i; UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); Sleep(1); } } blend.SourceConstantAlpha = 255; UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); if (DWORD_PTR(arg) > 0) { if (SetTimer(hwndSplash, 6, DWORD_PTR(arg), 0)) { #ifdef _DEBUG logMessage(_T("Timer TimeToShow"), _T("set")); #endif } } else if (bmodulesloaded) { if (SetTimer(hwndSplash, 8, 2000, 0)) { #ifdef _DEBUG logMessage(_T("Timer Modules loaded"), _T("set")); #endif } } // The Message Pump MSG msg; while (GetMessage(&msg, NULL, 0, 0) == TRUE) //NULL means every window in the thread; == TRUE means a safe pump. { TranslateMessage(&msg); DispatchMessage(&msg); } if (options.playsnd) { pControl->Release(); pGraph->Release(); CoUninitialize(); } }
INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct FileDlgData *dat; dat=(struct FileDlgData*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { TCHAR *contactName; TCHAR szPath[450]; CLISTEVENT* cle = (CLISTEVENT*)lParam; TranslateDialogDefault(hwndDlg); dat=(struct FileDlgData*)mir_calloc(sizeof(struct 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")); contactName = cli.pfnGetContactDisplayName( dat->hContact, 0 ); SetDlgItemText(hwndDlg,IDC_FROM,contactName); GetContactReceivedFilesDir(dat->hContact,szPath,SIZEOF(szPath),TRUE); SetDlgItemText(hwndDlg,IDC_FILEDIR,szPath); { int i; char idstr[32]; DBVARIANT dbv; if (shAutoComplete) shAutoComplete(GetWindow(GetDlgItem(hwndDlg,IDC_FILEDIR),GW_CHILD),1); for(i=0;i<MAX_MRU_DIRS;i++) { mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d",i); if(DBGetContactSettingTString(NULL,"SRFile",idstr,&dbv)) break; SendDlgItemMessage(hwndDlg,IDC_FILEDIR,CB_ADDSTRING,0,(LPARAM)dbv.ptszVal); DBFreeVariant(&dbv); } } CallService(MS_DB_EVENT_MARKREAD,(WPARAM)dat->hContact,(LPARAM)dat->hDbEvent); { DBEVENTINFO dbei={0}; TCHAR datetimestr[64]; char buf[540]; dbei.cbSize=sizeof(dbei); dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)dat->hDbEvent,0); dbei.pBlob=(PBYTE)mir_alloc(dbei.cbBlob); CallService(MS_DB_EVENT_GET,(WPARAM)dat->hDbEvent,(LPARAM)&dbei); dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob; lstrcpynA(buf, (char*)dbei.pBlob+4, min(dbei.cbBlob+1,SIZEOF(buf))); TCHAR* ptszFileName = DbGetEventStringT( &dbei, buf ); SetDlgItemText(hwndDlg,IDC_FILENAMES,ptszFileName); mir_free(ptszFileName); lstrcpynA(buf, (char*)dbei.pBlob+4+strlen((char*)dbei.pBlob+4)+1, min((int)(dbei.cbBlob-4-strlen((char*)dbei.pBlob+4)),SIZEOF(buf))); TCHAR* ptszDescription = DbGetEventStringT( &dbei, buf ); SetDlgItemText(hwndDlg,IDC_MSG,ptszDescription); mir_free(ptszDescription); mir_free(dbei.pBlob); tmi.printTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, SIZEOF(datetimestr), 0); SetDlgItemText(hwndDlg, IDC_DATE, datetimestr); } { char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); if (szProto) { CONTACTINFO ci; int hasName = 0; char buf[128]; ZeroMemory(&ci,sizeof(ci)); 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(DBGetContactSettingByte(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(DBGetContactSettingByte(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(!DBGetContactSettingByte(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; szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); if (szProto) { HICON 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(DBGetContactSettingTString(NULL,"SRFile",idstr,&dbv)) continue; mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d",i+1); DBWriteContactSettingTString(NULL,"SRFile",idstr,dbv.ptszVal); DBFreeVariant(&dbv); } DBWriteContactSettingTString(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(DBGetContactSettingByte(NULL,"SRFile","AutoAccept",0) && DBGetContactSettingByte(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("Cancelled")); dat->fs=NULL; /* the protocol will free the handle */ DestroyWindow(hwndDlg); break; case IDC_ADD: { ADDCONTACTSTRUCT acs={0}; acs.handle=dat->hContact; acs.handleType=HANDLE_CONTACT; acs.szProto=""; CallService(MS_ADDCONTACT_SHOW,(WPARAM)hwndDlg,(LPARAM)&acs); if(!DBGetContactSettingByte(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; }
void fnLoadClcOptions(HWND hwnd, struct ClcData *dat) { dat->rowHeight = db_get_b(NULL, "CLC", "RowHeight", CLCDEFAULT_ROWHEIGHT); LOGFONT lf; SIZE fontSize; HDC hdc = GetDC(hwnd); for (int i=0; i <= FONTID_MAX; i++) { if (!dat->fontInfo[i].changed) DeleteObject(dat->fontInfo[i].hFont); cli.pfnGetFontSetting(i, &lf, &dat->fontInfo[i].colour); lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72); dat->fontInfo[i].hFont = CreateFontIndirect(&lf); dat->fontInfo[i].changed = 0; HFONT holdfont = (HFONT)SelectObject(hdc, dat->fontInfo[i].hFont); GetTextExtentPoint32(hdc, _T("x"), 1, &fontSize); SelectObject(hdc, holdfont); dat->fontInfo[i].fontHeight = fontSize.cy; } ReleaseDC(hwnd, hdc); dat->leftMargin = db_get_b(NULL, "CLC", "LeftMargin", CLCDEFAULT_LEFTMARGIN); dat->exStyle = db_get_dw(NULL, "CLC", "ExStyle", cli.pfnGetDefaultExStyle()); dat->scrollTime = db_get_w(NULL, "CLC", "ScrollTime", CLCDEFAULT_SCROLLTIME); dat->groupIndent = db_get_b(NULL, "CLC", "GroupIndent", CLCDEFAULT_GROUPINDENT); dat->gammaCorrection = db_get_b(NULL, "CLC", "GammaCorrect", CLCDEFAULT_GAMMACORRECT); dat->showIdle = db_get_b(NULL, "CLC", "ShowIdle", CLCDEFAULT_SHOWIDLE); dat->noVScrollbar = db_get_b(NULL, "CLC", "NoVScrollBar", 0); dat->filterSearch = db_get_b(NULL, "CLC", "FilterSearch", 1); SendMessage(hwnd, INTM_SCROLLBARCHANGED, 0, 0); if (!dat->bkChanged) { DBVARIANT dbv; dat->bkColour = db_get_dw(NULL, "CLC", "BkColour", CLCDEFAULT_BKCOLOUR); if (dat->hBmpBackground) { DeleteObject(dat->hBmpBackground); dat->hBmpBackground = NULL; } if (db_get_b(NULL, "CLC", "UseBitmap", CLCDEFAULT_USEBITMAP)) { if (!db_get_s(NULL, "CLC", "BkBitmap", &dbv)) { dat->hBmpBackground = (HBITMAP) CallService(MS_UTILS_LOADBITMAP, 0, (LPARAM) dbv.pszVal); mir_free(dbv.pszVal); } } dat->backgroundBmpUse = db_get_w(NULL, "CLC", "BkBmpUse", CLCDEFAULT_BKBMPUSE); } dat->greyoutFlags = db_get_dw(NULL, "CLC", "GreyoutFlags", CLCDEFAULT_GREYOUTFLAGS); dat->offlineModes = db_get_dw(NULL, "CLC", "OfflineModes", CLCDEFAULT_OFFLINEMODES); dat->selBkColour = db_get_dw(NULL, "CLC", "SelBkColour", CLCDEFAULT_SELBKCOLOUR); dat->selTextColour = db_get_dw(NULL, "CLC", "SelTextColour", CLCDEFAULT_SELTEXTCOLOUR); dat->hotTextColour = db_get_dw(NULL, "CLC", "HotTextColour", CLCDEFAULT_HOTTEXTCOLOUR); dat->quickSearchColour = db_get_dw(NULL, "CLC", "QuickSearchColour", CLCDEFAULT_QUICKSEARCHCOLOUR); dat->useWindowsColours = db_get_b(NULL, "CLC", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS); NMHDR hdr; hdr.code = CLN_OPTIONSCHANGED; hdr.hwndFrom = hwnd; hdr.idFrom = GetDlgCtrlID(hwnd); SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM) & hdr); SendMessage(hwnd, WM_SIZE, 0, 0); }
static LRESULT CALLBACK OptionsFilterSubclassProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (message != WM_PAINT && message != WM_PRINT) return mir_callNextSubclass(hWnd, OptionsFilterSubclassProc, message, wParam, lParam); if (GetFocus() == hWnd || GetWindowTextLength(hWnd)) return mir_callNextSubclass(hWnd, OptionsFilterSubclassProc, message, wParam, lParam); RECT rc; GetClientRect(hWnd, &rc); PAINTSTRUCT paint; HDC hdc = (message == WM_PAINT) ? BeginPaint(hWnd, &paint) : (HDC)wParam; TCHAR buf[255]; if (bSearchState == 1 && FilterLoadProgress < 100 && FilterLoadProgress > 0) mir_sntprintf(buf, TranslateT("Loading... %d%%"), FilterLoadProgress); else mir_sntprintf(buf, TranslateT("Search")); bool bDrawnByTheme = false; int oldMode = SetBkMode(hdc, TRANSPARENT); HTHEME hTheme = OpenThemeData(hWnd, L"EDIT"); if (hTheme) { if (IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL)) DrawThemeParentBackground(hWnd, hdc, &rc); RECT rc2; GetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &rc, &rc2); rc2.top = 2 * rc.top - rc2.top; rc2.left = 2 * rc.left - rc2.left; rc2.bottom = 2 * rc.bottom - rc2.bottom; rc2.right = 2 * rc.right - rc2.right; DrawThemeBackground(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &rc2, &rc); HFONT hFont = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0); HFONT oldFont = (HFONT)SelectObject(hdc, hFont); wchar_t *bufW = mir_t2u(buf); DrawThemeText(hTheme, hdc, EP_EDITTEXT, ETS_DISABLED, bufW, -1, 0, 0, &rc); mir_free(bufW); SelectObject(hdc, oldFont); CloseThemeData(hTheme); bDrawnByTheme = true; } SetBkMode(hdc, oldMode); if (!bDrawnByTheme) { HFONT hFont = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0); HFONT oldFont = (HFONT)SelectObject(hdc, hFont); SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); FillRect(hdc, &rc, GetSysColorBrush(COLOR_WINDOW)); oldMode = SetBkMode(hdc, TRANSPARENT); DrawText(hdc, buf, -1, &rc, 0); SetBkMode(hdc, oldMode); SelectObject(hdc, oldFont); } if (message == WM_PAINT) EndPaint(hWnd, &paint); return 0; }
void CMsnProto::MSN_SetServerStatus(int newStatus) { debugLogA("Setting MSN server status %d, logged in = %d", newStatus, msnLoggedIn); if (!msnLoggedIn) return; if (isIdle) newStatus = ID_STATUS_IDLE; const char* szStatusName = MirandaStatusToMSN(newStatus); if (newStatus != ID_STATUS_OFFLINE) { DBVARIANT msnObject = {0}; if (ServiceExists(MS_AV_SETMYAVATAR)) getString("PictObject", &msnObject); // Capabilties: WLM 2009, Chunking, UUN Bootstrap myFlags = 0xA0000000 | cap_SupportsChunking | cap_SupportsP2PBootstrap | cap_SupportsSipInvite; if (getByte("MobileEnabled", 0) && getByte("MobileAllowed", 0)) myFlags |= cap_MobileEnabled; unsigned myFlagsEx = capex_SupportsPeerToPeerV2; char szMsg[256]; if (m_iStatus < ID_STATUS_ONLINE) { int sz = mir_snprintf(szMsg, sizeof(szMsg), "<EndpointData><Capabilities>%u:%u</Capabilities></EndpointData>", myFlags, myFlagsEx); msnNsThread->sendPacket( "UUX", "%d\r\n%s", sz, szMsg ); msnNsThread->sendPacket("BLP", msnOtherContactsBlocked ? "BL" : "AL"); DBVARIANT dbv; if (!getStringUtf("Nick", &dbv)) { if (dbv.pszVal[0]) MSN_SetNicknameUtf(dbv.pszVal); db_free(&dbv); } } char *szPlace; DBVARIANT dbv; if (!getStringUtf("Place", &dbv)) szPlace = dbv.pszVal; else { TCHAR buf[128] = _T("Miranda"); DWORD buflen = SIZEOF(buf); GetComputerName(buf, &buflen); szPlace = mir_utf8encodeT(buf); } int sz = mir_snprintf(szMsg, sizeof(szMsg), "<PrivateEndpointData>" "<EpName>%s</EpName>" "<Idle>%s</Idle>" "<ClientType>1</ClientType>" "<State>%s</State>" "</PrivateEndpointData>", szPlace, newStatus == ID_STATUS_IDLE ? "true" : "false", szStatusName); msnNsThread->sendPacket("UUX", "%d\r\n%s", sz, szMsg); mir_free(szPlace); if (newStatus != ID_STATUS_IDLE) { char** msgptr = GetStatusMsgLoc(newStatus); if (msgptr != NULL) MSN_SendStatusMessage(*msgptr); } msnNsThread->sendPacket("CHG", "%s %u:%u %s", szStatusName, myFlags, myFlagsEx, msnObject.pszVal ? msnObject.pszVal : "0"); db_free(&msnObject); } else msnNsThread->sendPacket("CHG", szStatusName); }
INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct UrlRcvData *dat = (struct UrlRcvData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_URL); 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")); dat = (struct UrlRcvData*)mir_alloc(sizeof(struct UrlRcvData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = ((CLISTEVENT*)lParam)->hContact; dat->hDbEvent = ((CLISTEVENT*)lParam)->hDbEvent; WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact); { DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = db_event_getBlobSize(dat->hDbEvent); dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); db_event_get(dat->hDbEvent, &dbei); SetDlgItemTextA(hwndDlg, IDC_URL, (char*)dbei.pBlob); SetDlgItemTextA(hwndDlg, IDC_MSG, (char*)dbei.pBlob+lstrlenA((char*)dbei.pBlob)+1); mir_free(dbei.pBlob); db_event_markRead(dat->hContact, dat->hDbEvent); TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0), msg[128]; mir_sntprintf(msg, SIZEOF(msg), TranslateT("URL from %s"), contactName); SetWindowText(hwndDlg, msg); SetDlgItemText(hwndDlg, IDC_FROM, contactName); SendDlgItemMessage(hwndDlg, IDOK, BUTTONSETARROW, 1, 0); TCHAR str[128]; tmi.printTimeStamp(NULL, dbei.timestamp, _T("t d"), str, SIZEOF(str), 0); SetDlgItemText(hwndDlg, IDC_DATE, str); } // From message dlg if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0); // From message dlg end Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "recv"); 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; szProto = GetContactProto(dat->hContact); if (szProto) { HICON 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 DM_UPDATETITLE: sttUpdateTitle(hwndDlg, dat->hContact); break; case WM_COMMAND: if (dat) if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) break; switch(LOWORD(wParam)) { case IDOK: { HMENU hMenu, hSubMenu; RECT rc; char url[256]; hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); hSubMenu = GetSubMenu(hMenu, 6); TranslateMenu(hSubMenu); GetWindowRect((HWND)lParam, &rc); GetDlgItemTextA(hwndDlg, IDC_URL, url, SIZEOF(url)); switch(TrackPopupMenu(hSubMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, hwndDlg, NULL)) { case IDM_OPENNEW: CallService(MS_UTILS_OPENURL, 1, (LPARAM)url); break; case IDM_OPENEXISTING: CallService(MS_UTILS_OPENURL, 0, (LPARAM)url); break; case IDM_COPYLINK: { HGLOBAL hData; if ( !OpenClipboard(hwndDlg)) break; EmptyClipboard(); hData = GlobalAlloc(GMEM_MOVEABLE, lstrlenA(url)+1); lstrcpyA((char*)GlobalLock(hData), url); GlobalUnlock(hData); SetClipboardData(CF_TEXT, hData); CloseClipboard(); break; } } DestroyMenu(hMenu); } return TRUE; case IDC_USERMENU: { RECT rc; HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_HISTORY: CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_ADD: { ADDCONTACTSTRUCT acs = {0}; acs.hContact = dat->hContact; acs.handleType = HANDLE_CONTACT; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); } if ( !db_get_b(dat->hContact, "CList", "NotOnList", 0)) { ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); } break; case IDC_REPLY: CallService(MS_MSG_SENDMESSAGE, (WPARAM)dat->hContact, 0); //fall through case IDCANCEL: DestroyWindow(hwndDlg); return TRUE; } 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); WindowList_Remove(hUrlWindowList, hwndDlg); mir_free(dat); Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "recv"); break; } return FALSE; }
static int CustomButtonPressed(WPARAM, LPARAM lParam) { CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam; CHARRANGE cr; HWND hEdit = NULL; BOOL bCTRL = 0; BOOL bIsService = 0; TCHAR* pszText = NULL; TCHAR* pszCBText = NULL; TCHAR* ptszQValue = NULL; UINT textlenght = 0; SortedList* sl = NULL; int state = 0; if (mir_strcmp(cbcd->pszModule, PLGNAME)) return 0; if (!ButtonsList[cbcd->dwButtonId]) return 1; sl = ButtonsList[cbcd->dwButtonId]->sl; if (!sl) return 1; if (IsClipboardFormatAvailable(CF_TEXT)) { if (OpenClipboard(cbcd->hwndFrom)) { HANDLE hData = NULL; TCHAR* chBuffer = NULL; int textLength = 0; hData = GetClipboardData(CF_UNICODETEXT); chBuffer = (TCHAR*)GlobalLock(hData); textLength = (int)mir_tstrlen(chBuffer); pszCBText = mir_tstrdup(chBuffer); GlobalUnlock(hData); CloseClipboard(); } } qsort(sl->items, sl->realCount, sizeof(ButtonData *), sstSortButtons); hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE); if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE); cr.cpMin = cr.cpMax = 0; SendMessage(hEdit, EM_EXGETSEL, 0, (LPARAM)&cr); textlenght = cr.cpMax - cr.cpMin; if (textlenght) { pszText = (TCHAR *)mir_alloc((textlenght + 10)*sizeof(TCHAR)); memset(pszText, 0, ((textlenght + 10) * sizeof(TCHAR))); SendMessage(hEdit, EM_GETSELTEXT, 0, (LPARAM)pszText); } if (cbcd->flags&BBCF_RIGHTBUTTON) state = 1; else if (sl->realCount == 1) state = 2; else state = 3; switch (state) { case 1: if (ButtonsList[cbcd->dwButtonId]->ptszQValue) ptszQValue = ParseString(cbcd->hContact, ButtonsList[cbcd->dwButtonId]->ptszQValue, pszText ? pszText : _T(""), pszCBText ? pszCBText : _T(""), (int)mir_tstrlen(ButtonsList[cbcd->dwButtonId]->ptszQValue), textlenght, pszCBText ? (int)mir_tstrlen(pszCBText) : 0); if ((bIsService = ButtonsList[cbcd->dwButtonId]->bIsServName) && ptszQValue) CallService(mir_u2a(ptszQValue), (WPARAM)cbcd->hContact, 0); break; case 2: { ButtonData *bd = (ButtonData *)sl->items[0]; if (bd && bd->pszValue) { ptszQValue = ParseString(cbcd->hContact, bd->pszValue, pszText ? pszText : _T(""), pszCBText ? pszCBText : _T(""), (int)mir_tstrlen(bd->pszValue), textlenght, pszCBText ? (int)mir_tstrlen(pszCBText) : 0); if ((bIsService = bd->bIsServName) && ptszQValue) CallService(mir_u2a(ptszQValue), (WPARAM)cbcd->hContact, 0); } } break; case 3: if (!g_iButtonsCount) break; HMENU hMenu = CreatePopupMenu(), hSubMenu = NULL; for (int menunum = 0; menunum < sl->realCount; menunum++) { ButtonData *bd = (ButtonData *)sl->items[menunum]; if (bd->dwOPFlags&QMF_NEW) continue; BOOL bSetPopupMark = FALSE; if (bd->pszValue == 0 && bd->fEntryType == 0) { hSubMenu = CreatePopupMenu(); bSetPopupMark = TRUE; } if (bd->pszValue && bd->fEntryType == 0) hSubMenu = NULL; if (bd->fEntryType&QMF_EX_SEPARATOR) AppendMenu((HMENU)((hSubMenu && !bSetPopupMark) ? hSubMenu : hMenu), MF_SEPARATOR, 0, NULL); else AppendMenu((HMENU)((hSubMenu && !bSetPopupMark) ? hSubMenu : hMenu), MF_STRING | (bSetPopupMark ? MF_POPUP : 0), (bSetPopupMark ? (UINT_PTR)hSubMenu : (menunum + 1)), bd->pszName); } int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, NULL); if (res == 0) break; ButtonData *bd = (ButtonData *)sl->items[res - 1]; bCTRL = (GetKeyState(VK_CONTROL) & 0x8000) ? 1 : 0; if (bd->pszValue) { ptszQValue = ParseString(cbcd->hContact, bd->pszValue, pszText ? pszText : _T(""), pszCBText ? pszCBText : _T(""), (int)mir_tstrlen(bd->pszValue), textlenght, pszCBText ? (int)mir_tstrlen(pszCBText) : 0); if ((bIsService = bd->bIsServName) && ptszQValue) CallService(mir_u2a(ptszQValue), (WPARAM)cbcd->hContact, 0); } break; } if (ptszQValue) { if (!bIsService) { SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)ptszQValue); if ((g_bLClickAuto&&state != 1) || (g_bRClickAuto&&state == 1) || cbcd->flags&BBCF_CONTROLPRESSED || bCTRL) SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0); } free(ptszQValue); } mir_free(pszText); mir_free(pszCBText); return 1; }
void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_MAP * pmAllFields) { LIST<TCHAR> ListOfNonEmptyFields(20,(LIST<TCHAR>::FTSortFunc)TCharKeyCmp); LIST<TCHAR> ListOfFields(20); LIST<void>* plUsersInfo = (LIST<void>*)pvUsersInfo; int i, nUsersFound = plUsersInfo->getCount(); // lets fill the ListOfNonEmptyFields but in users order for (i=0; i < nUsersFound; i++) { U_TCHAR_MAP* pmUserData = (U_TCHAR_MAP*)plUsersInfo->operator [](i); int nUserFields = pmUserData->getCount(); for (int j=0; j < nUserFields; j++) { TCHAR *var = pmUserData->getKeyName(j); if (var && ListOfNonEmptyFields.getIndex(var) < 0) ListOfNonEmptyFields.insert(var); } } // now fill the ListOfFields but order is from pmAllFields int nAllCount = pmAllFields->getCount(); for (i=0; i < nAllCount; i++) { TCHAR * var=pmAllFields->getUnOrderedKeyName(i); if (var && ListOfNonEmptyFields.getIndex(var) < 0) continue; ListOfFields.insert(var); } // now lets transfer field names int nFieldCount = ListOfFields.getCount(); JABBER_CUSTOMSEARCHRESULTS Results={0}; Results.nSize=sizeof(Results); Results.pszFields=(TCHAR**)mir_alloc(sizeof(TCHAR*)*nFieldCount); Results.nFieldCount=nFieldCount; /* Sending Columns Titles */ for (i=0; i < nFieldCount; i++) { TCHAR *var = ListOfFields[i]; if (var) Results.pszFields[i] = pmAllFields->operator [](var); } Results.jsr.hdr.cbSize = 0; // sending column names ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM) &Results); /* Sending Users Data */ Results.jsr.hdr.cbSize = sizeof(Results.jsr); // sending user data for (i=0; i < nUsersFound; i++) { TCHAR buff[200]=_T(""); Results.jsr.jid[0]=0; U_TCHAR_MAP * pmUserData = (U_TCHAR_MAP *) plUsersInfo->operator [](i); for (int j=0; j < nFieldCount; j++) { TCHAR* var = ListOfFields[j]; TCHAR* value = pmUserData->operator [](var); Results.pszFields[j] = value ? value : (TCHAR *)_T(" "); if (!_tcsicmp(var,_T("jid")) && value) _tcsncpy(Results.jsr.jid, value, SIZEOF(Results.jsr.jid)); } { TCHAR * nickfields[]={ _T("nick"), _T("nickname"), _T("fullname"), _T("name"), _T("given"), _T("first"), _T("jid"), NULL }; TCHAR * nick=NULL; int k=0; while (nickfields[k] && !nick) nick=pmUserData->operator [](nickfields[k++]); if (_tcsicmp(nick, Results.jsr.jid)) mir_sntprintf(buff, SIZEOF(buff), _T("%s (%s)"), nick, Results.jsr.jid); else _tcsncpy(buff, nick, SIZEOF(buff)); Results.jsr.hdr.nick = nick ? buff : NULL; Results.jsr.hdr.flags = PSR_TCHAR; } ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM) &Results); Results.jsr.hdr.nick=NULL; } mir_free(Results.pszFields); }
CCtrlTreeOpts::COptionsItem::~COptionsItem() { mir_free(m_szOptionName); }
void DestroyKey(TCHAR* key) { mir_free(key); }
int HookedNewEvent(WPARAM wParam, LPARAM hDBEvent) { logmsg("HookedNewEvent1"); DBEVENTINFO dbe; dbe.cbSize = sizeof(dbe); dbe.cbBlob = db_event_getBlobSize(hDBEvent); if (dbe.cbBlob == -1) return 0; dbe.pBlob = (PBYTE) malloc(dbe.cbBlob); if(db_event_get(hDBEvent,&dbe)) return 0; if (dbe.flags & DBEF_SENT) return 0; if (db_get_b(NULL,THIS_MODULE, "messages", DEFAULT_ANNOUNCEMESSAGES)==0) return 0; if (!(db_get_dw(NULL,THIS_MODULE,"showWhen", DEFAULT_SHOWWHEN)&(1<<(db_get_w(NULL, "CList", "Status", ID_STATUS_OFFLINE)-ID_STATUS_OFFLINE)))) return 0; logmsg("HookedNewEvent2"); TCHAR buf[512]; _tcsncpy(buf, DEFAULT_MESSAGEFORMAT,_countof(buf)); DBVARIANT dbv; if(!db_get_ts(NULL,THIS_MODULE,"message_format",&dbv)) { mir_tstrcpy(buf, dbv.ptszVal); db_free(&dbv); } int i1=-1, i2=-1; TCHAR* pbuf = buf; while (*pbuf) { if (*pbuf=='%') { if (*(pbuf+1)=='n') { if (i1==-1) i1=1; else i2=1; *(pbuf+1)='s'; } else if (*(pbuf+1)=='m') { if (i1==-1) i1=2; else i2=2; *(pbuf+1)='s'; } else if (*(pbuf+1)=='l') { *pbuf=0x0d; *(pbuf+1)=0x0a; } } pbuf++; } TCHAR *c1 = 0, *c2 = 0; if ( i1 == 1 ) c1 = mir_tstrdup(pcli->pfnGetContactDisplayName(wParam, 0)); else if ( i1 == 2 ) c1 = DbGetEventTextT( &dbe, 0 ); if ( i2 == 1 ) c2 = mir_tstrdup(pcli->pfnGetContactDisplayName(wParam, 0)); else if ( i2 == 2 ) c2 = DbGetEventTextT( &dbe, 0 ); TCHAR buffer[512]; mir_sntprintf(buffer, _countof(buffer), buf, c1, c2); ShowOSD(buffer, 0, db_get_dw(NULL,THIS_MODULE, "clr_msg", DEFAULT_CLRMSG), wParam); mir_free( c1 ); mir_free( c2 ); return 0; }
static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { JabberSearchData* dat = (JabberSearchData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { dat = (JabberSearchData *)mir_calloc(sizeof(JabberSearchData)); dat->ppro = (CJabberProto*)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); /* Server Combo box */ ptrA jud(dat->ppro->getStringA("Jud")); char *szServerName = (jud == NULL) ? "users.jabber.org": jud; SetDlgItemTextA(hwndDlg,IDC_SERVER,szServerName); SendDlgItemMessageA(hwndDlg,IDC_SERVER,CB_ADDSTRING,0,(LPARAM)szServerName); //TO DO: Add Transports here int i, transpCount = dat->ppro->m_lstTransports.getCount(); for (i=0; i < transpCount; i++) { TCHAR *szTransp = dat->ppro->m_lstTransports[i]; if (szTransp) JabberSearchAddUrlToRecentCombo(hwndDlg, szTransp); } for (i=0; i < 10; i++) { char key[30]; mir_snprintf(key, SIZEOF(key), "RecentlySearched_%d", i); ptrT szValue( dat->ppro->getTStringA(key)); if (szValue != NULL) JabberSearchAddUrlToRecentCombo(hwndDlg, szValue); } //TO DO: Add 4 recently used dat->lastRequestIq = dat->ppro->SearchRenewFields(hwndDlg,dat); } return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDC_SERVER) { switch (HIWORD(wParam)) { case CBN_SETFOCUS: PostMessage(GetParent(hwndDlg),WM_COMMAND, MAKEWPARAM(0,EN_SETFOCUS), (LPARAM)hwndDlg); return TRUE; case CBN_EDITCHANGE: EnableWindow(GetDlgItem(hwndDlg, IDC_GO),TRUE); return TRUE; case CBN_EDITUPDATE: JabberSearchFreeData(hwndDlg, dat); EnableWindow(GetDlgItem(hwndDlg, IDC_GO),TRUE); return TRUE; case CBN_SELENDOK: EnableWindow(GetDlgItem(hwndDlg, IDC_GO),TRUE); PostMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_GO,BN_CLICKED),0); return TRUE; } } else if (LOWORD(wParam) == IDC_GO && HIWORD(wParam) == BN_CLICKED) { dat->ppro->SearchRenewFields(hwndDlg, dat); return TRUE; } break; case WM_SIZE: { //Resize IDC_FRAME to take full size RECT rcForm; GetWindowRect(hwndDlg, &rcForm); RECT rcFrame; GetWindowRect(GetDlgItem(hwndDlg, IDC_FRAME), &rcFrame); rcFrame.bottom = rcForm.bottom; SetWindowPos(GetDlgItem(hwndDlg,IDC_FRAME),NULL,0,0,rcFrame.right-rcFrame.left,rcFrame.bottom-rcFrame.top,SWP_NOZORDER|SWP_NOMOVE); GetWindowRect(GetDlgItem(hwndDlg,IDC_VSCROLL), &rcForm); SetWindowPos(GetDlgItem(hwndDlg,IDC_VSCROLL),NULL,0,0,rcForm.right-rcForm.left,rcFrame.bottom-rcFrame.top,SWP_NOZORDER|SWP_NOMOVE); JabberSearchRefreshFrameScroll(hwndDlg, dat); } return TRUE; case WM_USER+11: { dat->fSearchRequestIsXForm=TRUE; dat->xNode = (HXML)wParam; JabberFormCreateUI(GetDlgItem(hwndDlg, IDC_FRAME), dat->xNode, &dat->CurrentHeight,TRUE); ShowWindow(GetDlgItem(hwndDlg, IDC_FRAME), SW_SHOW); dat->nJSInfCount=1; return TRUE; } case WM_USER+10: { Data* MyDat = (Data*)lParam; if (MyDat) { dat->fSearchRequestIsXForm = (BOOL)wParam; dat->CurrentHeight = JabberSearchAddField(hwndDlg,MyDat); mir_free(MyDat->Label); mir_free(MyDat->Var); mir_free(MyDat->defValue); free(MyDat); } else { JabberSearchRefreshFrameScroll(hwndDlg,dat); ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - 0, NULL, &(dat->frameRect)); SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, 0, FALSE); dat->curPos=0; } return TRUE; } case WM_MOUSEWHEEL: { int zDelta = GET_WHEEL_DELTA_WPARAM(wParam); if (zDelta) { int nScrollLines=0; SystemParametersInfo(SPI_GETWHEELSCROLLLINES,0,(void*)&nScrollLines,0); for (int i=0; i<(nScrollLines+1)/2; i++) SendMessage(hwndDlg,WM_VSCROLL, (zDelta<0)?SB_LINEDOWN:SB_LINEUP,0); } } return TRUE; case WM_VSCROLL: { int pos; if (dat != NULL) { pos = dat->curPos; switch (LOWORD(wParam)) { case SB_LINEDOWN: pos += 10; break; case SB_LINEUP: pos -= 10; break; case SB_PAGEDOWN: pos += (dat->CurrentHeight - 10); break; case SB_PAGEUP: pos -= (dat->CurrentHeight - 10); break; case SB_THUMBTRACK: pos = HIWORD(wParam); break; } if (pos > (dat->CurrentHeight - dat->frameHeight)) pos = dat->CurrentHeight - dat->frameHeight; if (pos < 0) pos = 0; if (dat->curPos != pos) { ScrollWindow(GetDlgItem(hwndDlg, IDC_FRAME), 0, dat->curPos - pos, NULL , &(dat->frameRect)); SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, pos, TRUE); RECT Invalid=dat->frameRect; if (dat->curPos - pos >0) Invalid.bottom=Invalid.top+(dat->curPos - pos); else Invalid.top=Invalid.bottom+(dat->curPos - pos); RedrawWindow(GetDlgItem(hwndDlg, IDC_FRAME), NULL, NULL, RDW_UPDATENOW |RDW_ALLCHILDREN); dat->curPos = pos; } } } return TRUE; case WM_DESTROY: JabberSearchFreeData(hwndDlg, dat); JabberFormDestroyUI(GetDlgItem(hwndDlg, IDC_FRAME)); mir_free(dat); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0); return TRUE; } return FALSE; }
void CLC::RebuildEntireList(HWND hwnd, ClcData *dat) { char *szProto; DWORD style = GetWindowLong(hwnd, GWL_STYLE); MCONTACT hContact; ClcGroup *group; DBVARIANT dbv = {0}; RowHeight::Clear(dat); RowHeight::getMaxRowHeight(dat, hwnd); dat->list.expanded = 1; dat->list.hideOffline = cfg::getByte("CLC", "HideOfflineRoot", 0); dat->list.cl.count = 0; dat->list.totalMembers = 0; dat->selection = -1; dat->SelectMode = cfg::getByte("CLC", "SelectMode", 0); { int i; wchar_t *szGroupName; DWORD groupFlags; for (i = 1; ; i++) { szGroupName = pcli->pfnGetGroupName(i, &groupFlags); if (szGroupName == NULL) break; pcli->pfnAddGroup(hwnd, dat, szGroupName, groupFlags, i, 0); } } hContact = db_find_first(); while (hContact) { if (style & CLS_SHOWHIDDEN || !CLVM_GetContactHiddenStatus(hContact, NULL, dat)) { ZeroMemory((void *)&dbv, sizeof(dbv)); if (cfg::getTString(hContact, "CList", "Group", &dbv)) group = &dat->list; else { group = pcli->pfnAddGroup(hwnd, dat, dbv.ptszVal, (DWORD) - 1, 0, 0); mir_free(dbv.ptszVal); } if (group != NULL) { group->totalMembers++; if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) { szProto = GetContactProto(hContact); if (szProto == NULL) { if (!pcli->pfnIsHiddenMode(dat, ID_STATUS_OFFLINE)) AddContactToGroup(dat, group, hContact); } else if (!pcli->pfnIsHiddenMode(dat, (WORD) cfg::getWord(hContact, szProto, "Status", ID_STATUS_OFFLINE))) AddContactToGroup(dat, group, hContact); } else AddContactToGroup(dat, group, hContact); } } hContact = db_find_next(hContact); } if (style & CLS_HIDEEMPTYGROUPS) { group = &dat->list; group->scanIndex = 0; for (; ;) { if (group->scanIndex == group->cl.count) { group = group->parent; if (group == NULL) break; } else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) { if (group->cl.items[group->scanIndex]->group->cl.count == 0) { group = pcli->pfnRemoveItemFromGroup(hwnd, group, group->cl.items[group->scanIndex], 0); } else { group = group->cl.items[group->scanIndex]->group; group->scanIndex = 0; } continue; } group->scanIndex++; } } pcli->pfnSortCLC(hwnd, dat, 0); pcli->pfnSetAllExtraIcons(NULL); if(!dat->bisEmbedded) FLT_SyncWithClist(); }
TWinErrorCode::~TWinErrorCode() { mir_free(mErrorText); }
void SaveStateAndRebuildList(HWND hwnd,struct ClcData *dat) { NMCLISTCONTROL nm; int i,j; struct SavedGroupState_t *savedGroup = NULL; int savedGroupCount = 0,savedGroupAlloced = 0; struct SavedContactState_t *savedContact = NULL; int savedContactCount = 0,savedContactAlloced = 0; struct SavedInfoState_t *savedInfo = NULL; int savedInfoCount = 0,savedInfoAlloced = 0; ClcGroup *group; struct ClcContact *contact; int tick = GetTickCount(); int allocstep = 1024; pcli->pfnHideInfoTip(hwnd,dat); KillTimer(hwnd,TIMERID_INFOTIP); KillTimer(hwnd,TIMERID_RENAME); pcli->pfnEndRename(hwnd,dat,1); group = &dat->list; group->scanIndex = 0; for (;;) { if (group->scanIndex == group->cl.count) { group = group->parent; if (group == NULL) break; } else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) { group = group->cl.items[group->scanIndex]->group; group->scanIndex = 0; if (++savedGroupCount>savedGroupAlloced) { savedGroupAlloced += allocstep; savedGroup = (struct SavedGroupState_t*)mir_realloc(savedGroup,sizeof(struct SavedGroupState_t)*savedGroupAlloced); } savedGroup[savedGroupCount-1].groupId = group->groupId; savedGroup[savedGroupCount-1].expanded = group->expanded; continue; } else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) { if (++savedContactCount>savedContactAlloced) { savedContactAlloced += allocstep; savedContact = (struct SavedContactState_t*)mir_realloc(savedContact,sizeof(struct SavedContactState_t)*savedContactAlloced); } savedContact[savedContactCount-1].hContact = group->cl.items[group->scanIndex]->hContact; memcpy(savedContact[savedContactCount-1].iExtraImage, group->cl.items[group->scanIndex]->iExtraImage, sizeof(contact->iExtraImage)); savedContact[savedContactCount-1].checked = group->cl.items[group->scanIndex]->flags & CONTACTF_CHECKED; if (group->cl.items[group->scanIndex]->SubAllocated>0) { int l; for (l = 0; l<group->cl.items[group->scanIndex]->SubAllocated; l++) { if (++savedContactCount>savedContactAlloced) { savedContactAlloced += allocstep; savedContact = (struct SavedContactState_t*)mir_realloc(savedContact,sizeof(struct SavedContactState_t)*savedContactAlloced); } savedContact[savedContactCount-1].hContact = group->cl.items[group->scanIndex]->subcontacts[l].hContact; memcpy(savedContact[savedContactCount-1].iExtraImage, group->cl.items[group->scanIndex]->subcontacts[l].iExtraImage, sizeof(contact->iExtraImage)); savedContact[savedContactCount-1].checked = group->cl.items[group->scanIndex]->subcontacts[l].flags&CONTACTF_CHECKED; } } } else if (group->cl.items[group->scanIndex]->type == CLCIT_INFO) { if (++savedInfoCount>savedInfoAlloced) { savedInfoAlloced += allocstep; savedInfo = (struct SavedInfoState_t*)mir_realloc(savedInfo,sizeof(struct SavedInfoState_t)*savedInfoAlloced); } if (group->parent == NULL) savedInfo[savedInfoCount-1].parentId = -1; else savedInfo[savedInfoCount-1].parentId = group->groupId; savedInfo[savedInfoCount-1].contact = *group->cl.items[group->scanIndex]; } group->scanIndex++; } pcli->pfnFreeGroup(&dat->list); RebuildEntireList(hwnd,dat); group = &dat->list; group->scanIndex = 0; for (;;) { if (group->scanIndex == group->cl.count) { group = group->parent; if (group == NULL) break; } else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) { group = group->cl.items[group->scanIndex]->group; group->scanIndex = 0; for (i = 0;i<savedGroupCount;i++) if (savedGroup[i].groupId == group->groupId) { group->expanded = savedGroup[i].expanded; break; } continue; } else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) { for (i = 0;i<savedContactCount;i++) if (savedContact[i].hContact == group->cl.items[group->scanIndex]->hContact) { memcpy(group->cl.items[group->scanIndex]->iExtraImage, savedContact[i].iExtraImage, sizeof(contact->iExtraImage)); if (savedContact[i].checked) group->cl.items[group->scanIndex]->flags |= CONTACTF_CHECKED; break; } if (group->cl.items[group->scanIndex]->SubAllocated>0) { for (int l = 0; l<group->cl.items[group->scanIndex]->SubAllocated; l++) for (i = 0;i<savedContactCount;i++) if (savedContact[i].hContact == group->cl.items[group->scanIndex]->subcontacts[l].hContact) { memcpy(group->cl.items[group->scanIndex]->subcontacts[l].iExtraImage, savedContact[i].iExtraImage, sizeof(contact->iExtraImage)); if (savedContact[i].checked) group->cl.items[group->scanIndex]->subcontacts[l].flags |= CONTACTF_CHECKED; break; } } } group->scanIndex++; } if (savedGroup) mir_free(savedGroup); if (savedContact) mir_free(savedContact); for (i = 0;i<savedInfoCount;i++) { if (savedInfo[i].parentId == -1) group = &dat->list; else { if ( !FindItem(hwnd,dat,(HANDLE)(savedInfo[i].parentId|HCONTACT_ISGROUP),&contact,NULL,NULL)) continue; group = contact->group; } j = AddInfoItemToGroup(group,savedInfo[i].contact.flags,_T("")); *group->cl.items[j] = savedInfo[i].contact; } if (savedInfo) mir_free(savedInfo); pcli->pfnRecalculateGroupCheckboxes(hwnd,dat); RecalcScrollBar(hwnd,dat); nm.hdr.code = CLN_LISTREBUILT; nm.hdr.hwndFrom = hwnd; nm.hdr.idFrom = GetDlgCtrlID(hwnd); //srand(GetTickCount()); tick = GetTickCount()-tick; { char buf[255]; //sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick); mir_snprintf(buf, SIZEOF(buf), "SaveStateAndRebuildList %d \r\n", tick); OutputDebugStringA(buf); } ClearRowByIndexCache(); SendMessage(GetParent(hwnd),WM_NOTIFY,0,(LPARAM)&nm); }
int CMsnProto::MSN_SetMyAvatar(const TCHAR* sztFname, void* pData, size_t cbLen) { mir_sha1_ctx sha1ctx; BYTE sha1c[MIR_SHA1_HASH_SIZE], sha1d[MIR_SHA1_HASH_SIZE]; char *szFname = mir_utf8encodeT(sztFname); mir_sha1_init(&sha1ctx); mir_sha1_append(&sha1ctx, (BYTE*)pData, (int)cbLen); mir_sha1_finish(&sha1ctx, sha1d); ptrA szSha1d( mir_base64_encode((PBYTE)sha1d, sizeof(sha1d))); mir_sha1_init(&sha1ctx); ezxml_t xmlp = ezxml_new("msnobj"); mir_sha1_append(&sha1ctx, (PBYTE)"Creator", 7); mir_sha1_append(&sha1ctx, (PBYTE)MyOptions.szEmail, (int)strlen(MyOptions.szEmail)); ezxml_set_attr(xmlp, "Creator", MyOptions.szEmail); char szFileSize[20]; _ultoa((unsigned)cbLen, szFileSize, 10); mir_sha1_append(&sha1ctx, (PBYTE)"Size", 4); mir_sha1_append(&sha1ctx, (PBYTE)szFileSize, (int)strlen(szFileSize)); ezxml_set_attr(xmlp, "Size", szFileSize); mir_sha1_append(&sha1ctx, (PBYTE)"Type", 4); mir_sha1_append(&sha1ctx, (PBYTE)"3", 1); // MSN_TYPEID_DISPLAYPICT ezxml_set_attr(xmlp, "Type", "3"); mir_sha1_append(&sha1ctx, (PBYTE)"Location", 8); mir_sha1_append(&sha1ctx, (PBYTE)szFname, (int)strlen(szFname)); ezxml_set_attr(xmlp, "Location", szFname); mir_sha1_append(&sha1ctx, (PBYTE)"Friendly", 8); mir_sha1_append(&sha1ctx, (PBYTE)"AAA=", 4); ezxml_set_attr(xmlp, "Friendly", "AAA="); mir_sha1_append(&sha1ctx, (PBYTE)"SHA1D", 5); mir_sha1_append(&sha1ctx, (PBYTE)(char*)szSha1d, (int)strlen(szSha1d)); ezxml_set_attr(xmlp, "SHA1D", szSha1d); mir_sha1_finish(&sha1ctx, sha1c); ptrA szSha1c( mir_base64_encode((PBYTE)sha1c, sizeof(sha1c))); // ezxml_set_attr(xmlp, "SHA1C", szSha1c); char* szBuffer = ezxml_toxml(xmlp, false); ezxml_free(xmlp); mir_free(szFname); ptrA szEncodedBuffer(mir_urlEncode(szBuffer)); free(szBuffer); const TCHAR *szExt; int fmt = ProtoGetBufferFormat(pData, &szExt); if (fmt == PA_FORMAT_UNKNOWN) return fmt; TCHAR szFileName[MAX_PATH]; MSN_GetAvatarFileName(NULL, szFileName, SIZEOF(szFileName), NULL); _tremove(szFileName); MSN_GetAvatarFileName(NULL, szFileName, SIZEOF(szFileName), szExt); int fileId = _topen(szFileName, _O_CREAT | _O_TRUNC | _O_WRONLY | O_BINARY, _S_IREAD | _S_IWRITE); if (fileId >= 0) { _write(fileId, pData, (unsigned)cbLen); _close(fileId); char szAvatarHashdOld[41] = ""; db_get_static(NULL, m_szModuleName, "AvatarHash", szAvatarHashdOld, sizeof(szAvatarHashdOld)); char *szAvatarHash = arrayToHex(sha1d, sizeof(sha1d)); if (strcmp(szAvatarHashdOld, szAvatarHash)) { setString("PictObject", szEncodedBuffer); setString("AvatarHash", szAvatarHash); } mir_free(szAvatarHash); } else MSN_ShowError("Cannot set avatar. File '%s' could not be created/overwritten", szFileName); return fmt; }
bool ipcGetSortedContacts(THeaderIPC *ipch, int *pSlot, bool bGroupMode) { DBVARIANT dbv; int n, rc; bool Result = false; // hide offliners? bool bHideOffline = db_get_b(0, "CList", "HideOffline", 0) == 1; // do they wanna hide the offline people anyway? if (db_get_b(0, SHLExt_Name, SHLExt_ShowNoOffline, 0) == 1) // hide offline people bHideOffline = true; // get the number of contacts int dwContacts = (int)CallService(MS_DB_CONTACT_GETCOUNT, 0, 0); if (dwContacts == 0) return false; // get the contacts in the array to be sorted by status, trim out anyone // who doesn't wanna be seen. TSlotInfo *pContacts = (TSlotInfo*)mir_alloc((dwContacts + 2) * sizeof(TSlotInfo)); int i = 0; int dwOnline = 0; for (MCONTACT hContact = db_find_first(); hContact != 0; hContact = db_find_next(hContact)) { if (i >= dwContacts) break; // do they have a running protocol? char *szProto = GetContactProto(hContact); if (szProto != NULL) { // does it support file sends? DWORD dwCaps = ProtoCallService(szProto, PS_GETCAPS, PFLAGNUM_1, 0); if ((dwCaps & PF1_FILESEND) == 0) continue; int dwStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); if (dwStatus != ID_STATUS_OFFLINE) dwOnline++; else if (bHideOffline) continue; // is HIT on? if (BST_UNCHECKED == db_get_b(0, SHLExt_Name, SHLExt_UseHITContacts, BST_UNCHECKED)) { // don't show people who are "Hidden" "NotOnList" or Ignored if (db_get_b(hContact, "CList", "Hidden", 0) == 1 || db_get_b(hContact, "CList", "NotOnList", 0) == 1 || CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_MESSAGE | IGNOREEVENT_URL | IGNOREEVENT_FILE) != 0) continue; } // is HIT2 off? if (BST_UNCHECKED == db_get_b(0, SHLExt_Name, SHLExt_UseHIT2Contacts, BST_UNCHECKED)) if (db_get_w(hContact, szProto, "ApparentMode", 0) == ID_STATUS_OFFLINE) continue; // store pContacts[i].hContact = hContact; pContacts[i].dwStatus = dwStatus; pContacts[i].hProto = murmur_hash(szProto); i++; } } // if no one is online and the CList isn't showing offliners, quit if (dwOnline == 0 && bHideOffline) { mir_free(pContacts); return false; } dwContacts = i; qsort(pContacts, dwContacts, sizeof(TSlotInfo), SortContact); // create an IPC slot for each contact and store display name, etc for (i=0; i < dwContacts; i++) { char *szContact = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)pContacts[i].hContact, 0); if (szContact != NULL) { n = 0; rc = 1; if (bGroupMode) { rc = db_get_s(pContacts[i].hContact, "CList", "Group", &dbv); if (!rc) n = lstrlenA(dbv.pszVal) + 1; } int cch = lstrlenA(szContact) + 1; TSlotIPC *pct = ipcAlloc(ipch, cch + 1 + n); if (pct == NULL) { db_free(&dbv); break; } // lie about the actual size of the TSlotIPC pct->cbStrSection = cch; LPSTR szSlot = LPSTR(pct) + sizeof(TSlotIPC); lstrcpyA(szSlot, szContact); pct->fType = REQUEST_CONTACTS; pct->hContact = pContacts[i].hContact; pct->Status = pContacts[i].dwStatus; pct->hProto = pContacts[i].hProto; pct->MRU = db_get_b(pct->hContact, SHLExt_Name, SHLExt_MRU, 0); if (ipch->ContactsBegin == NULL) ipch->ContactsBegin = pct; szSlot += cch + 1; if (rc == 0) { pct->hGroup = murmur_hash(dbv.pszVal); lstrcpyA(szSlot, dbv.pszVal); db_free(&dbv); } else { pct->hGroup = 0; *szSlot = 0; } pSlot[0]++; } } mir_free(pContacts); return true; }
void CMsnProto::MSN_SendStatusMessage(const char* msg) { if (!msnLoggedIn) return; char* msgEnc = HtmlEncode(msg ? msg : ""); size_t sz; char szMsg[2048]; if (msnCurrentMedia.cbSize == 0) { sz = mir_snprintf(szMsg, sizeof(szMsg), "<Data><PSM>%s</PSM><CurrentMedia></CurrentMedia><MachineGuid>%s</MachineGuid>" "<DDP></DDP><SignatureSound></SignatureSound><Scene></Scene><ColorScheme></ColorScheme></Data>", msgEnc, MyOptions.szMachineGuid); } else { char *szFormatEnc; if (ServiceExists(MS_LISTENINGTO_GETPARSEDTEXT)) { LISTENINGTOINFO lti = {0}; lti.cbSize = sizeof(lti); if (msnCurrentMedia.ptszTitle != NULL) lti.ptszTitle = _T("{0}"); if (msnCurrentMedia.ptszArtist != NULL) lti.ptszArtist = _T("{1}"); if (msnCurrentMedia.ptszAlbum != NULL) lti.ptszAlbum = _T("{2}"); if (msnCurrentMedia.ptszTrack != NULL) lti.ptszTrack = _T("{3}"); if (msnCurrentMedia.ptszYear != NULL) lti.ptszYear = _T("{4}"); if (msnCurrentMedia.ptszGenre != NULL) lti.ptszGenre = _T("{5}"); if (msnCurrentMedia.ptszLength != NULL) lti.ptszLength = _T("{6}"); if (msnCurrentMedia.ptszPlayer != NULL) lti.ptszPlayer = _T("{7}"); if (msnCurrentMedia.ptszType != NULL) lti.ptszType = _T("{8}"); TCHAR *tmp = (TCHAR *)CallService(MS_LISTENINGTO_GETPARSEDTEXT, (WPARAM) _T("%title% - %artist%"), (LPARAM) <i); szFormatEnc = HtmlEncodeUTF8T(tmp); mir_free(tmp); } else szFormatEnc = HtmlEncodeUTF8T(_T("{0} - {1}")); char *szArtist = HtmlEncodeUTF8T(msnCurrentMedia.ptszArtist); char *szAlbum = HtmlEncodeUTF8T(msnCurrentMedia.ptszAlbum); char *szTitle = HtmlEncodeUTF8T(msnCurrentMedia.ptszTitle); char *szTrack = HtmlEncodeUTF8T(msnCurrentMedia.ptszTrack); char *szYear = HtmlEncodeUTF8T(msnCurrentMedia.ptszYear); char *szGenre = HtmlEncodeUTF8T(msnCurrentMedia.ptszGenre); char *szLength = HtmlEncodeUTF8T(msnCurrentMedia.ptszLength); char *szPlayer = HtmlEncodeUTF8T(msnCurrentMedia.ptszPlayer); char *szType = HtmlEncodeUTF8T(msnCurrentMedia.ptszType); sz = mir_snprintf(szMsg, sizeof szMsg, "<Data>" "<PSM>%s</PSM>" "<CurrentMedia>%s\\0%s\\01\\0%s\\0%s\\0%s\\0%s\\0%s\\0%s\\0%s\\0%s\\0%s\\0%s\\0\\0</CurrentMedia>" "<MachineGuid>%s</MachineGuid><DDP></DDP><SignatureSound></SignatureSound><Scene></Scene><ColorScheme></ColorScheme>" "<DDP></DDP><SignatureSound></SignatureSound><Scene></Scene><ColorScheme></ColorScheme>" "</Data>", msgEnc, szPlayer, szType, szFormatEnc, szTitle, szArtist, szAlbum, szTrack, szYear, szGenre, szLength, szPlayer, szType, MyOptions.szMachineGuid); mir_free(szArtist); mir_free(szAlbum); mir_free(szTitle); mir_free(szTrack); mir_free(szYear); mir_free(szGenre); mir_free(szLength); mir_free(szPlayer); mir_free(szType); } mir_free(msgEnc); if (msnPreviousUUX == NULL || strcmp(msnPreviousUUX, szMsg)) { replaceStr(msnPreviousUUX, szMsg); msnNsThread->sendPacket("UUX", "%d\r\n%s", sz, szMsg); mStatusMsgTS = clock(); } }
//////////////////////////////////////////////////////////////////////////////// // Info Page : Proc // lParam: 0 if current user (account owner) details, hContact if on list user details static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct GGDETAILSDLGDATA *dat = (struct GGDETAILSDLGDATA *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch(msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); dat = (struct GGDETAILSDLGDATA *)mir_alloc(sizeof(struct GGDETAILSDLGDATA)); dat->hContact = lParam; dat->disableUpdate = FALSE; dat->updating = FALSE; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); // Add genders if (!dat->hContact) { SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_ADDSTRING, 0, (LPARAM)_T("")); // 0 SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_ADDSTRING, 0, (LPARAM)TranslateT("Female")); // 1 SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_ADDSTRING, 0, (LPARAM)TranslateT("Male")); // 2 } break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_PARAMCHANGED: dat->gg = (GGPROTO *)((LPPSHNOTIFY)lParam)->lParam; break; case PSN_INFOCHANGED: { MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam; GGPROTO *gg = dat->gg; if (!dat) break; // Show updated message if (dat->updating) { MessageBox(NULL, TranslateT("Your details has been uploaded to the public directory."), gg->m_tszUserName, MB_OK | MB_ICONINFORMATION); dat->updating = FALSE; break; } char *szProto = (hContact == NULL) ? gg->m_szModuleName : GetContactProto(hContact); if (szProto == NULL) break; // Disable when updating dat->disableUpdate = TRUE; SetValue(hwndDlg, IDC_UIN, hContact, szProto, GG_KEY_UIN, 0, hContact != NULL); SetValue(hwndDlg, IDC_REALIP, hContact, szProto, GG_KEY_CLIENTIP, SVS_IP, hContact != NULL); SetValue(hwndDlg, IDC_PORT, hContact, szProto, GG_KEY_CLIENTPORT, SVS_ZEROISUNSPEC, hContact != NULL); SetValue(hwndDlg, IDC_VERSION, hContact, szProto, GG_KEY_CLIENTVERSION, SVS_GGVERSION, hContact != NULL); SetValue(hwndDlg, IDC_FIRSTNAME, hContact, szProto, GG_KEY_PD_FIRSTNAME, SVS_NORMAL, hContact != NULL); SetValue(hwndDlg, IDC_LASTNAME, hContact, szProto, GG_KEY_PD_LASTNAME, SVS_NORMAL, hContact != NULL); SetValue(hwndDlg, IDC_NICKNAME, hContact, szProto, GG_KEY_PD_NICKNAME, SVS_NORMAL, hContact != NULL); SetValue(hwndDlg, IDC_BIRTHYEAR, hContact, szProto, GG_KEY_PD_BIRTHYEAR, SVS_ZEROISUNSPEC, hContact != NULL); SetValue(hwndDlg, IDC_CITY, hContact, szProto, GG_KEY_PD_CITY, SVS_NORMAL, hContact != NULL); SetValue(hwndDlg, IDC_FAMILYNAME, hContact, szProto, GG_KEY_PD_FAMILYNAME, SVS_NORMAL, hContact != NULL); SetValue(hwndDlg, IDC_CITYORIGIN, hContact, szProto, GG_KEY_PD_FAMILYCITY , SVS_NORMAL, hContact != NULL); if (hContact) { SetValue(hwndDlg, IDC_GENDER, hContact, szProto, GG_KEY_PD_GANDER, SVS_GENDER, hContact != NULL); SetValue(hwndDlg, IDC_STATUSDESCR, hContact, "CList", GG_KEY_STATUSDESCR, SVS_NORMAL, hContact != NULL); } else switch((char)db_get_b(hContact, gg->m_szModuleName, GG_KEY_PD_GANDER, (BYTE)'?')) { case 'F': SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_SETCURSEL, 1, 0); break; case 'M': SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_SETCURSEL, 2, 0); break; default: SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_SETCURSEL, 0, 0); } // Disable when updating dat->disableUpdate = FALSE; break; } } break; } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: SendMessage(GetParent(hwndDlg),msg,wParam,lParam); break; case IDC_NICKNAME: case IDC_FIRSTNAME: case IDC_LASTNAME: case IDC_FAMILYNAME: case IDC_CITY: case IDC_CITYORIGIN: case IDC_BIRTHYEAR: if (HIWORD(wParam) == EN_CHANGE) { if (!dat || dat->hContact || dat->disableUpdate) break; EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE), TRUE); break; } case IDC_GENDER: if (HIWORD(wParam) == CBN_SELCHANGE) { if (!dat || dat->hContact || dat->disableUpdate) break; EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE), TRUE); break; } case IDC_SAVE: // Save current user data if (HIWORD(wParam) == BN_CLICKED) { if (!dat || dat->hContact || dat->disableUpdate) break; { TCHAR text[256]; GGPROTO *gg = dat->gg; if (!gg->isonline()) { MessageBox(NULL, TranslateT("You have to be logged in before you can change your details."), gg->m_tszUserName, MB_OK | MB_ICONSTOP); break; } EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE), FALSE); gg_pubdir50_t req = gg_pubdir50_new(GG_PUBDIR50_WRITE); GetDlgItemText(hwndDlg, IDC_FIRSTNAME, text, _countof(text)); if (mir_tstrlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_FIRSTNAME, T2Utf(text)); GetDlgItemText(hwndDlg, IDC_LASTNAME, text, _countof(text)); if (mir_tstrlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_LASTNAME, T2Utf(text)); GetDlgItemText(hwndDlg, IDC_NICKNAME, text, _countof(text)); if (mir_tstrlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_NICKNAME, T2Utf(text)); GetDlgItemText(hwndDlg, IDC_CITY, text, _countof(text)); if (mir_tstrlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_CITY, T2Utf(text)); // Gadu-Gadu Female <-> Male switch(SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_GETCURSEL, 0, 0)) { case 1: gg_pubdir50_add(req, GG_PUBDIR50_GENDER, GG_PUBDIR50_GENDER_SET_FEMALE); break; case 2: gg_pubdir50_add(req, GG_PUBDIR50_GENDER, GG_PUBDIR50_GENDER_SET_MALE); break; default: gg_pubdir50_add(req, GG_PUBDIR50_GENDER, ""); } GetDlgItemText(hwndDlg, IDC_BIRTHYEAR, text, _countof(text)); if (mir_tstrlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_BIRTHYEAR, T2Utf(text)); GetDlgItemText(hwndDlg, IDC_FAMILYNAME, text, _countof(text)); if (mir_tstrlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_FAMILYNAME, T2Utf(text)); GetDlgItemText(hwndDlg, IDC_CITYORIGIN, text, _countof(text)); if (mir_tstrlen(text)) gg_pubdir50_add(req, GG_PUBDIR50_FAMILYCITY, T2Utf(text)); // Run update gg_pubdir50_seq_set(req, GG_SEQ_CHINFO); gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_detailsdlgproc", 35, "sess_mutex", 1); gg_pubdir50(gg->sess, req); gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 35, 1, "sess_mutex", 1); dat->updating = TRUE; gg_pubdir50_free(req); } break; } } break; case WM_DESTROY: if (dat) mir_free(dat); break; } return FALSE; }
static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { struct TFtMgrData *dat = (struct TFtMgrData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { TCITEM tci = {0}; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); TranslateDialogDefault(hwnd); Window_SetIcon_IcoLib(hwnd, SKINICON_EVENT_FILE); dat = (struct TFtMgrData *)mir_calloc(sizeof(struct TFtMgrData)); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat); dat->hhkPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwnd, M_PRESHUTDOWN); dat->hwndIncoming = CreateDialog(hMirandaInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc); dat->hwndOutgoing = CreateDialog(hMirandaInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc); ShowWindow(dat->hwndIncoming, SW_SHOW); tci.mask = TCIF_PARAM|TCIF_TEXT; tci.pszText = TranslateT("Incoming"); tci.lParam = (LPARAM)dat->hwndIncoming; TabCtrl_InsertItem(hwndTab, 0, &tci); tci.pszText = TranslateT("Outgoing"); tci.lParam = (LPARAM)dat->hwndOutgoing; TabCtrl_InsertItem(hwndTab, 1, &tci); // Utils_RestoreWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_"); SAVEWINDOWPOS swp; swp.hwnd=hwnd; swp.hContact=NULL; swp.szModule="SRFile"; swp.szNamePrefix="FtMgrDlg_"; CallService(MS_UTILS_RESTOREWINDOWPOSITION, RWPF_NOACTIVATE, (LPARAM)&swp); // Fall through to setup initial placement } case WM_SIZE: { RECT rc, rcButton; HDWP hdwp; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rcButton); OffsetRect(&rcButton, -rcButton.left, -rcButton.top); GetClientRect(hwnd, &rc); InflateRect(&rc, -6, -6); hdwp = BeginDeferWindowPos(3); hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_CLEAR), NULL, rc.left, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE); hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDCANCEL), NULL, rc.right-rcButton.right, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE); rc.bottom -= rcButton.bottom + 5; hdwp = DeferWindowPos(hdwp, hwndTab, NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); EndDeferWindowPos(hdwp); GetWindowRect(hwndTab, &rc); MapWindowPoints(NULL, hwnd, (LPPOINT)&rc, 2); TabCtrl_AdjustRect(hwndTab, FALSE, &rc); InflateRect(&rc, -5, -5); hdwp = BeginDeferWindowPos(2); hdwp = DeferWindowPos(hdwp, dat->hwndIncoming, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0); hdwp = DeferWindowPos(hdwp, dat->hwndOutgoing, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0); EndDeferWindowPos(hdwp); break; } case WM_MOUSEWHEEL: { if (IsWindowVisible(dat->hwndIncoming)) SendMessage(dat->hwndIncoming, msg, wParam, lParam); if (IsWindowVisible(dat->hwndOutgoing)) SendMessage(dat->hwndOutgoing, msg, wParam, lParam); break; } case WM_FT_SELECTPAGE: { TCITEM tci = {0}; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); if (TabCtrl_GetCurSel(hwndTab) == (int)wParam) break; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_HIDE); TabCtrl_SetCurSel(hwndTab, wParam); TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_SHOW); break; } case WM_GETMINMAXINFO: { LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; lpmmi->ptMinTrackSize.x = 300; lpmmi->ptMinTrackSize.y = 400; return 0; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: PostMessage(hwnd, WM_CLOSE , 0, 0); break; case IDC_CLEAR: PostMessage(dat->hwndIncoming, WM_FT_CLEANUP, 0, 0); PostMessage(dat->hwndOutgoing, WM_FT_CLEANUP, 0, 0); break; } break; case WM_NOTIFY: { switch (((LPNMHDR)lParam)->idFrom) { case IDC_TABS: { HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); switch (((LPNMHDR)lParam)->code) { case TCN_SELCHANGING: { TCITEM tci = {0}; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_HIDE); break; } case TCN_SELCHANGE: { TCITEM tci = {0}; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_SHOW); break; } } break; } } break; } case M_PRESHUTDOWN: SendMessage(dat->hwndIncoming, M_PRESHUTDOWN, 0, 0); SendMessage(dat->hwndOutgoing, M_PRESHUTDOWN, 0, 0); DestroyWindow(hwnd); break; case WM_CLOSE: ShowWindow(hwnd, SW_HIDE); if (DBGetContactSettingByte(NULL, "SRFile", "AutoClear", 1)) { PostMessage(dat->hwndIncoming, WM_FT_CLEANUP, 0, 0); PostMessage(dat->hwndOutgoing, WM_FT_CLEANUP, 0, 0); } return TRUE; /* Disable default IDCANCEL notification */ case WM_DESTROY: UnhookEvent(dat->hhkPreshutdown); Window_FreeIcon_IcoLib(hwnd); DestroyWindow(dat->hwndIncoming); DestroyWindow(dat->hwndOutgoing); mir_free(dat); SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); Utils_SaveWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_"); break; case WM_ACTIVATE: { dat->errorState = TBPF_NOPROGRESS; wParam = 1; } break; case WM_SHOWWINDOW: { if (!wParam) // hiding { KillTimer(hwnd, 1); break; } lParam = 0; } case WM_TIMER: { if (pTaskbarInterface) { SetTimer(hwnd, 1, 400, NULL); if ((lParam == ACKRESULT_FAILED) || (lParam == ACKRESULT_DENIED)) dat->errorState = TBPF_ERROR; TFtProgressData prg = {0}; SendMessage(dat->hwndIncoming, M_CALCPROGRESS, (WPARAM)&prg, 0); SendMessage(dat->hwndOutgoing, M_CALCPROGRESS, (WPARAM)&prg, 0); if (dat->errorState) { pTaskbarInterface->SetProgressState(hwnd, dat->errorState); if (!prg.run) pTaskbarInterface->SetProgressValue(hwnd, 1, 1); } else if (prg.run) { pTaskbarInterface->SetProgressState(hwnd, TBPF_NORMAL); } else if (prg.init || prg.scan) { pTaskbarInterface->SetProgressState(hwnd, TBPF_INDETERMINATE); } else { pTaskbarInterface->SetProgressState(hwnd, TBPF_NOPROGRESS); KillTimer(hwnd, 1); } if (prg.run) { pTaskbarInterface->SetProgressValue(hwnd, prg.totalProgress, prg.totalBytes); } } } break; } return FALSE; }