void ChangeProtoMessages(char* szProto, int iMode, TCString &Msg) { TCString CurMsg(Msg); if (szProto) { if (Msg == NULL) { CurMsg = GetDynamicStatMsg(INVALID_HANDLE_VALUE, szProto); } CallAllowedPS_SETAWAYMSG(szProto, iMode, (char*)TCHAR2ANSI(CurMsg)); g_ProtoStates[szProto].CurStatusMsg = CurMsg; } else // change message of all protocols { int ProtoCount; PROTOCOLDESCRIPTOR **proto; CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&ProtoCount, (LPARAM)&proto); int I; for (I = 0; I < ProtoCount; I++) { if (proto[I]->type == PROTOTYPE_PROTOCOL && !DBGetContactSettingByte(NULL, proto[I]->szName, "LockMainStatus", 0)) { if (Msg == NULL) { CurMsg = GetDynamicStatMsg(INVALID_HANDLE_VALUE, proto[I]->szName); } CallAllowedPS_SETAWAYMSG(proto[I]->szName, iMode, (char*)TCHAR2ANSI(CurMsg)); g_ProtoStates[proto[I]->szName].CurStatusMsg = CurMsg; } } } static struct { int Status; char *Setting; } StatusSettings[] = { ID_STATUS_OFFLINE, "Off", ID_STATUS_ONLINE, "On", ID_STATUS_AWAY, "Away", ID_STATUS_NA, "Na", ID_STATUS_DND, "Dnd", ID_STATUS_OCCUPIED, "Occupied", ID_STATUS_FREECHAT, "FreeChat", ID_STATUS_INVISIBLE, "Inv", ID_STATUS_ONTHEPHONE, "Otp", ID_STATUS_OUTTOLUNCH, "Otl", ID_STATUS_IDLE, "Idl" }; int I; for (I = 0; I < lengthof(StatusSettings); I++) { if (iMode == StatusSettings[I].Status) { DBWriteContactSettingTString(NULL, "SRAway", CString(StatusSettings[I].Setting) + "Msg", CurMsg); DBWriteContactSettingTString(NULL, "SRAway", CString(StatusSettings[I].Setting) + "Default", CurMsg); // TODO: make it more accurate, and change not only here, but when changing status messages through UpdateMsgsTimerFunc too; and when changing messages through AutoAway() ? break; } } // InitUpdateMsgs(); }
void SkypeProfile_Save(SkypeProfile *pstProf) { DBWriteContactSettingByte(NULL, SKYPE_PROTONAME, "Gender", pstProf->Sex); DBWriteContactSettingString(NULL, SKYPE_PROTONAME, "HomePhone", pstProf->HomePhone); DBWriteContactSettingString(NULL, SKYPE_PROTONAME, "OfficePhone", pstProf->OfficePhone); DBWriteContactSettingString(NULL, SKYPE_PROTONAME, "HomePage", pstProf->HomePage); DBWriteContactSettingTString(NULL, SKYPE_PROTONAME, "Nick", pstProf->FullName); DBWriteContactSettingTString(NULL, SKYPE_PROTONAME, "City", pstProf->City); DBWriteContactSettingTString(NULL, SKYPE_PROTONAME, "Province", pstProf->Province); DBWriteContactSettingWord(NULL, SKYPE_PROTONAME, "BirthYear", (WORD)pstProf->Birthday.wYear); DBWriteContactSettingByte(NULL, SKYPE_PROTONAME, "BirthMonth", (BYTE)pstProf->Birthday.wMonth); DBWriteContactSettingByte(NULL, SKYPE_PROTONAME, "BirthDay", (BYTE)pstProf->Birthday.wDay); }
static int MoveGroupBefore(WPARAM wParam,LPARAM lParam) { int i,shuffleFrom,shuffleTo,shuffleDir; char str[33]; TCHAR *szMoveName; DBVARIANT dbv; if (wParam == 0 || (LPARAM) wParam == lParam) return 0; itoa(wParam-1,str,10); if (DBGetContactSettingTString(NULL, "CListGroups", str, &dbv)) return 0; szMoveName = dbv.ptszVal; //shuffle list of groups up to fill gap if (lParam == 0) { shuffleFrom = wParam - 1; shuffleTo = -1; shuffleDir = -1; } else { if ((LPARAM) wParam < lParam) { shuffleFrom = wParam - 1; shuffleTo = lParam - 2; shuffleDir = -1; } else { shuffleFrom = wParam - 1; shuffleTo = lParam - 1; shuffleDir = 1; } } if(shuffleDir==-1) { for(i=shuffleFrom;i!=shuffleTo;i++) { itoa(i+1,str,10); if (DBGetContactSettingStringUtf(NULL, "CListGroups", str, &dbv)) { shuffleTo = i; break; } itoa(i,str,10); DBWriteContactSettingStringUtf(NULL, "CListGroups", str, dbv.pszVal); DBFreeVariant(&dbv); } } else { for(i=shuffleFrom;i!=shuffleTo;i--) { itoa(i-1,str,10); if (DBGetContactSettingStringUtf(NULL, "CListGroups", str, &dbv)) { mir_free(szMoveName); return 1; } //never happens itoa(i,str,10); DBWriteContactSettingStringUtf(NULL, "CListGroups", str, dbv.pszVal); DBFreeVariant(&dbv); } } itoa(shuffleTo,str,10); DBWriteContactSettingTString(NULL, "CListGroups", str, szMoveName); mir_free(szMoveName); return shuffleTo+1; }
static int CreateGroup(WPARAM wParam,LPARAM lParam) { int newId=CountGroups(); TCHAR newBaseName[127], newName[128]; char str[33]; int i; DBVARIANT dbv; if(wParam) { itoa(wParam-1,str,10); if (DBGetContactSettingTString(NULL, "CListGroups", str, &dbv)) return 0; mir_sntprintf( newBaseName, SIZEOF(newBaseName), _T("%s\\%s"), dbv.pszVal + 1, TranslateT("New Group")); mir_free(dbv.pszVal); } else lstrcpyn( newBaseName, TranslateT( "New Group" ), SIZEOF( newBaseName )); itoa(newId,str,10); i=1; lstrcpyn( newName + 1, newBaseName, SIZEOF(newName) - 1); while(GroupNameExists(newName+1,-1)) mir_sntprintf( newName + 1, SIZEOF(newName) - 1, _T("%s (%d)"), newBaseName, ++i ); newName[0]=1|GROUPF_EXPANDED; //1 is required so we never get '\0' DBWriteContactSettingTString(NULL, "CListGroups", str, newName); CallService(MS_CLUI_GROUPADDED,newId+1,1); return newId+1; }
BOOL ResaveSettings(char* szName,int iFirst,int iLimit,TCHAR* szBuffer) { BYTE marked,marked_t; char szNameBuf[256]={0}; for (int i = iFirst; i < iLimit; i++) { if (szBuffer) { DBVARIANT dbv_temp = {0}; mir_snprintf(szNameBuf, SIZEOF(szNameBuf), "%s_%u", szName, i); DBGetContactSettingTString(NULL, __INTERNAL_NAME, szNameBuf, &dbv_temp); DBWriteContactSettingTString(NULL, __INTERNAL_NAME, szNameBuf, szBuffer); marked=IsMarkedUserDefSession(i); MarkUserDefSession(i,(BYTE)((i==iFirst)?IsMarkedUserDefSession(iFirst-1):marked_t)); marked_t=marked; mir_free(szBuffer); if (dbv_temp.ptszVal) { szBuffer = mir_tstrdup(dbv_temp.ptszVal); DBFreeVariant(&dbv_temp); } else return 0; } else break; } return 1; }
void CList_CreateGroup(TCHAR* group) { int i; char str[50]; TCHAR name[256]; DBVARIANT dbv; if (!group) return; for (i = 0;; i++) { itoa(i, str, 10); if ( DBGetContactSettingTString( NULL, "CListGroups", str, &dbv )) break; if ( dbv.pszVal[0] != '\0' && !lstrcmpi(dbv.ptszVal + 1, group)) { DBFreeVariant(&dbv); return; } DBFreeVariant(&dbv); } // CallService(MS_CLIST_GROUPCREATE, (WPARAM)group, 0); name[0] = 1 | GROUPF_EXPANDED; _tcsncpy(name + 1, group, SIZEOF(name) - 1); name[ lstrlen(group) + 1] = '\0'; DBWriteContactSettingTString(NULL, "CListGroups", str, name); CallService(MS_CLUI_GROUPADDED, i + 1, 0); }
static void JabberContactListCreateClistGroup( TCHAR* groupName ) { char str[33]; int i; DBVARIANT dbv; for ( i=0;;i++ ) { itoa( i, str, 10 ); if ( DBGetContactSettingTString( NULL, "CListGroups", str, &dbv )) break; TCHAR* name = dbv.ptszVal; if ( name[0]!='\0' && !_tcscmp( name+1, groupName )) { // Already exists, no need to create JFreeVariant( &dbv ); return; } JFreeVariant( &dbv ); } // Create new group with id = i ( str is the text representation of i ) TCHAR newName[128]; newName[0] = 1 | GROUPF_EXPANDED; _tcsncpy( newName+1, groupName, SIZEOF( newName )-1 ); newName[ SIZEOF( newName )-1] = '\0'; DBWriteContactSettingTString( NULL, "CListGroups", str, newName ); JCallService( MS_CLUI_GROUPADDED, i+1, 0 ); }
void CConfig::SaveFontSettings(int iFont) { if(iFont > FONT_SETTINGS -1 || iFont < 0) return; char szSetting[128]; // Height sprintf(szSetting,"Font%dHeight",iFont); DBWriteContactSettingByte(NULL, "MirandaG15", szSetting, m_logfont[iFont].lfHeight); // Style int style = 0; if(m_logfont[iFont].lfWeight == FW_BOLD) style |= FONTF_BOLD; if(m_logfont[iFont].lfItalic) style |= FONTF_ITALIC; sprintf(szSetting,"Font%dStyle",iFont); DBWriteContactSettingByte(NULL, "MirandaG15", szSetting, style); // Charset sprintf(szSetting,"Font%dCharset",iFont); DBWriteContactSettingByte(NULL, "MirandaG15", szSetting, m_logfont[iFont].lfCharSet); // Name sprintf(szSetting,"Font%dName",iFont); DBWriteContactSettingTString(NULL, "MirandaG15", szSetting, m_logfont[iFont].lfFaceName); UpdateFontSettings(iFont); }
void save_listbox_items() { bool is_contact; for(int i = 0; i < listbox_items.getCount(); ++i) { is_contact = (int)CallService(MS_DB_CONTACT_IS, (WPARAM)listbox_items[i].hContact, 0) == 1; if(!is_contact) { listbox_items[i].hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0); CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM )listbox_items[i].hContact, ( LPARAM )PROTO ); CallService(MS_IGNORE_IGNORE, (WPARAM)listbox_items[i].hContact, (WPARAM)IGNOREEVENT_USERONLINE); } DBWriteContactSettingTString(listbox_items[i].hContact, PROTO, "Nick", listbox_items[i].pszText); DBWriteContactSettingDword(listbox_items[i].hContact, PROTO, "TimezoneListIndex", listbox_items[i].timezone_list_index); DBWriteContactSettingWord(listbox_items[i].hContact, PROTO, "Status", ID_STATUS_ONLINE); DBWriteContactSettingTString(listbox_items[i].hContact, PROTO, "TZName", timezone_list[listbox_items[i].timezone_list_index].tcName); } DBWriteContactSettingWord(0, PROTO, "DataVersion", 1); // remove contacts in DB that have been removed from the list HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); char *proto; bool found; while ( hContact != NULL ) { proto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact,0 ); if ( proto && !strcmp( PROTO, proto)) { found = false; for(int i = 0; i < listbox_items.getCount(); i++) { if(listbox_items[i].hContact == hContact) { found = true; } } if(!found) { // remove prot first, so that our contact deleted event handler (if present) isn't activated HANDLE oldHContact = hContact; hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 ); CallService(MS_PROTO_REMOVEFROMCONTACT, (WPARAM)oldHContact, (LPARAM)PROTO); CallService(MS_DB_CONTACT_DELETE, (WPARAM)oldHContact, 0); } else hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 ); } else hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 ); } }
static int SaveTree(HWND hwndDlg) { TVITEM tvi; int count; TCHAR idstr[100]; char menuItemName[256], DBString[256], MenuNameItems[256]; int menupos; int MenuObjectId, runtimepos; TIntMenuObject* pimo; MenuItemOptData* iod; HWND hTree = GetDlgItem( hwndDlg, IDC_MENUITEMS ); if ( !GetCurrentMenuObjectID( hwndDlg, &MenuObjectId )) return 0; tvi.hItem = TreeView_GetRoot( hTree ); tvi.cchTextMax = 99; tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_HANDLE; tvi.pszText = idstr; count = 0; menupos = GetMenuObjbyId( MenuObjectId ); if ( menupos == -1 ) return -1; pimo = g_menus[menupos]; mir_snprintf( MenuNameItems, sizeof(MenuNameItems), "%s_Items", pimo->Name); runtimepos = 100; while ( tvi.hItem != NULL ) { TreeView_GetItem( hTree, &tvi ); iod = ( MenuItemOptData* )tvi.lParam; if ( iod->pimi ) { GetMenuItemName( iod->pimi, menuItemName, sizeof( menuItemName )); mir_snprintf( DBString, SIZEOF(DBString), "%s_visible", menuItemName ); DBWriteContactSettingByte( NULL, MenuNameItems, DBString, iod->show ); mir_snprintf( DBString, SIZEOF(DBString), "%s_pos", menuItemName ); DBWriteContactSettingDword( NULL, MenuNameItems, DBString, runtimepos ); mir_snprintf( DBString, SIZEOF(DBString), "%s_name", menuItemName ); if ( lstrcmp( iod->name, iod->defname ) != 0 ) DBWriteContactSettingTString( NULL, MenuNameItems, DBString, iod->name ); else DBDeleteContactSetting( NULL, MenuNameItems, DBString ); runtimepos += 100; } if ( iod->name && !_tcscmp( iod->name, STR_SEPARATOR) && iod->show ) runtimepos += SEPARATORPOSITIONINTERVAL; tvi.hItem = TreeView_GetNextSibling( hTree, tvi.hItem ); count++; } return 1; }
int ContactChangeGroup(WPARAM wParam, LPARAM lParam) { CallService(MS_CLUI_CONTACTDELETED, wParam, 0); if ((HANDLE) lParam == NULL) DBDeleteContactSetting((HANDLE) wParam, "CList", "Group"); else DBWriteContactSettingTString((HANDLE) wParam, "CList", "Group", GetGroupNameT(lParam, NULL)); CallService(MS_CLUI_CONTACTADDED, wParam, IconFromStatusMode((char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0), GetContactStatus((HANDLE) wParam), (HANDLE) wParam, NULL)); return 0; }
void save_listbox_items() { DBWriteContactSettingDword(0, "WorldTime", "NumEntries", listbox_items.getCount()); int index = 0; for(int i = 0; i < listbox_items.getCount(); i++, index++) { char p1[20], p2[20], p3[20], p4[20], p5[20]; mir_snprintf(p1, SIZEOF(p1), "Label%d", i); mir_snprintf(p2, SIZEOF(p2), "Index%d", i); mir_snprintf(p3, SIZEOF(p3), "Sunrise%d", i); mir_snprintf(p4, SIZEOF(p4), "Sunset%d", i); mir_snprintf(p5, SIZEOF(p5), "TZName%d", i); DBWriteContactSettingTString(0, "WorldTime", p1, listbox_items[i].pszText); DBWriteContactSettingDword(0, "WorldTime", p2, listbox_items[i].timezone_list_index); DBWriteContactSettingDword(0, "WorldTime", p3, listbox_items[i].sunrise.wHour * 60 + listbox_items[i].sunrise.wMinute); DBWriteContactSettingDword(0, "WorldTime", p4, listbox_items[i].sunset.wHour * 60 + listbox_items[i].sunset.wMinute); DBWriteContactSettingTString(0, "WorldTime", p5, timezone_list[listbox_items[i].timezone_list_index].tcName); } DBWriteContactSettingWord(0, "WorldTime", "DataVersion", 1); }
static void timeapiSetInfoByContact(HANDLE hContact, HANDLE hTZ) { MIM_TIMEZONE *tz = (MIM_TIMEZONE*)hTZ; if (hContact == NULL) return; if (tz) { DBWriteContactSettingTString(hContact, "UserInfo", "TzName", tz->tszName); DBWriteContactSettingByte(hContact, "UserInfo", "Timezone", (char)((tz->tzi.Bias + tz->tzi.StandardBias) / 30)); } else { DBDeleteContactSetting(hContact, "UserInfo", "TzName"); DBDeleteContactSetting(hContact, "UserInfo", "Timezone"); } }
static void convertOneProtocol( char* moduleName, char* iconName ) { char* pm = moduleName + strlen( moduleName ); char* pi = iconName + strlen( iconName ); DBVARIANT dbv; int i; for ( i = 0; i < SIZEOF(statusIcons); i++ ) { _itoa( statusIcons[i].id, pm, 10 ); if ( !DBGetContactSettingTString( NULL, "Icons", moduleName, &dbv ) ) { _itoa( i, pi, 10 ); DBWriteContactSettingTString( NULL, "SkinIcons", iconName, dbv.ptszVal ); DBFreeVariant( &dbv ); DBDeleteContactSetting( NULL, "Icons", moduleName ); } } }
void EndRename(HWND hwnd,struct ClcData *dat,int save) { HWND hwndEdit; if (!dat) return; hwndEdit=dat->hwndRenameEdit; if(dat->hwndRenameEdit==NULL) return; dat->hwndRenameEdit=NULL; if(save) { TCHAR text[120]; struct ClcContact *contact; GetWindowText(hwndEdit,text,sizeof(text)); if(GetRowByIndex(dat,dat->selection,&contact,NULL)!=-1) { if(lstrcmp(contact->szText,text)) { if(contact->type==CLCIT_GROUP&&!_tcsstr(text,TEXT("\\"))) { TCHAR szFullName[256]; if(contact->group->parent && contact->group->parent->parent) { TCHAR * tc=(TCHAR*)CallService(MS_CLIST_GROUPGETNAMET,(WPARAM)contact->group->parent->groupId,(LPARAM)(int*)NULL); _sntprintf(szFullName,sizeof(szFullName),TEXT("%s\\%s"),tc,text); } else lstrcpyn(szFullName,text,sizeof(szFullName)); CallService(MS_CLIST_GROUPRENAME,contact->groupId,(LPARAM)szFullName); } else if(contact->type==CLCIT_CONTACT) { TCHAR *otherName=mir_strdupT((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)contact->hContact,GCDNF_NOMYHANDLE|GCDNF_UNICODE/*|TODO: UNICODE*/)); InvalidateDisplayNameCacheEntry(contact->hContact); if(text[0]==TEXT('\0')) { DBDeleteContactSetting(contact->hContact,"CList","MyHandle"); } else { if(!lstrcmp(otherName,text)) DBDeleteContactSetting(contact->hContact,"CList","MyHandle"); else DBWriteContactSettingTString(contact->hContact,"CList","MyHandle",text); } if (otherName) mir_free(otherName); InvalidateDisplayNameCacheEntry(contact->hContact); } } } } DestroyWindow(hwndEdit); }
void * AddTempGroup(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flags,int groupId,int calcTotalMembers) { int i=0; int f=0; TCHAR * szGroupName; DWORD groupFlags; #ifdef UNICODE char *mbuf=u2a((TCHAR *)szName); #else char *mbuf=mir_strdup((char *)szName); #endif if (WildCompare(mbuf,"* Hidden Group",0)) { mir_free(mbuf); if(ServiceExists(MS_MC_ADDTOMETA)) return NULL; else return(&dat->list); } mir_free(mbuf); for(i=1;;i++) { szGroupName=(TCHAR*)CallService(MS_CLIST_GROUPGETNAMET,i,(LPARAM)&groupFlags); if(szGroupName==NULL) break; if (!MyStrCmpiT(szGroupName,szName)) f=1; } if (!f) { char buf[20]; TCHAR b2[255]; void * res=NULL; _snprintf(buf,sizeof(buf),"%d",(i-1)); _sntprintf(b2,sizeof(b2),_T("#%s"),szName); b2[0]=1|GROUPF_EXPANDED; DBWriteContactSettingTString(NULL,"CListGroups",buf,b2); CallService(MS_CLIST_GROUPGETNAMET,i,(LPARAM)&groupFlags); res=AddGroup(hwnd,dat,szName,groupFlags,i,0); return res; } return NULL; }
void * AddTempGroup(HWND hwnd,struct ClcData *dat,const TCHAR *szName,DWORD flags,int groupId,int calcTotalMembers) { int i=0; int f=0; TCHAR * szGroupName; DWORD groupFlags; #ifdef UNICODE char *mbuf=u2a((TCHAR *)szName); #else char *mbuf=mir_strdup((char *)szName); #endif if (WildCompare(mbuf,"-@-HIDDEN-GROUP-@-",0)) { mir_free(mbuf); return NULL; } mir_free(mbuf); for(i=1;;i++) { szGroupName = pcli->pfnGetGroupName(i,&groupFlags); if(szGroupName==NULL) break; if (!mir_tstrcmpi(szGroupName,szName)) f=1; } if (!f) { char buf[20]; TCHAR b2[255]; void * res=NULL; _snprintf(buf,sizeof(buf),"%d",(i-1)); _sntprintf(b2,sizeof(b2),_T("#%s"),szName); b2[0]=1|GROUPF_EXPANDED; DBWriteContactSettingTString(NULL,"CListGroups",buf,b2); pcli->pfnGetGroupName(i,&groupFlags); res=cli_AddGroup(hwnd,dat,szName,groupFlags,i,0); return res; } return NULL; }
// fired when the contacts avatar changes // wParam = hContact // lParam = struct avatarCacheEntry *cacheEntry // the event CAN pass a NULL pointer in lParam which means that the avatar has changed, // but is no longer valid (happens, when a contact removes his avatar, for example). // DONT DESTROY the bitmap handle passed in the struct avatarCacheEntry * // // It is also possible that this event passes 0 as wParam (hContact), in which case, // a protocol picture (pseudo - avatar) has been changed. static int AvatarChanged(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; CONTACTAVATARCHANGEDNOTIFICATION* avatar = (CONTACTAVATARCHANGEDNOTIFICATION*)lParam; if (hContact == NULL) { ShowDebugPopup(NULL, _T("AVH Debug"), _T("Invalid contact/avatar... skipping")); return 0; } char *proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); if (proto == NULL) { ShowDebugPopup(hContact, _T("AVH Debug"), _T("Invalid protocol... skipping")); return 0; } else if (metacontacts_proto != NULL && strcmp(metacontacts_proto, proto) == 0) { ShowDebugPopup(hContact, _T("AVH Debug"), _T("Ignoring metacontacts notification")); return 0; } DBVARIANT dbvOldHash = {0}; bool ret = (DBGetContactSettingTString(hContact,MODULE_NAME,"AvatarHash",&dbvOldHash) == 0); if (avatar == NULL) { if (!ret || !_tcscmp(dbvOldHash.ptszVal, _T("-"))) { //avoid duplicate "removed avatar" notifications //do not notify on an empty profile ShowDebugPopup(hContact, _T("AVH Debug"), _T("Removed avatar, no avatar before...skipping")); DBFreeVariant(&dbvOldHash); return 0; } SkinPlaySound("avatar_removed"); // Is a flash avatar or avs could not load it DBWriteContactSettingTString(hContact, MODULE_NAME, "AvatarHash", _T("-")); if (ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_removed) ShowPopup(hContact, NULL, opts.popup_removed); if (ContactEnabled(hContact, "LogToHistory", AVH_DEF_LOGTOHISTORY)) HistoryEvents_AddToHistorySimple(hContact, EVENTTYPE_AVATAR_CHANGE, 1, DBEF_READ); } else { if(ret && !_tcscmp(dbvOldHash.ptszVal, avatar->hash)) { // same avatar hash, skipping ShowDebugPopup(hContact, _T("AVH Debug"), _T("Hashes are the same... skipping")); DBFreeVariant(&dbvOldHash); return 0; } SkinPlaySound("avatar_changed"); DBWriteContactSettingTString(hContact, "AvatarHistory", "AvatarHash", avatar->hash); TCHAR history_filename[MAX_PATH] = _T(""); if (ContactEnabled(hContact, "LogToDisk", AVH_DEF_LOGTODISK)) { if (!opts.log_store_as_hash) { if (opts.log_per_contact_folders) { GetOldStyleAvatarName(history_filename, hContact); if (CopyImageFile(avatar->filename, history_filename)) ShowPopup(hContact, _T("Avatar History: Unable to save avatar"), history_filename); else ShowDebugPopup(hContact, _T("AVH Debug: File copied successfully"), history_filename); if (ServiceExists(MS_MC_GETMETACONTACT)) { HANDLE hMetaContact = (HANDLE) CallService(MS_MC_GETMETACONTACT, wParam, 0); if (hMetaContact != NULL && ContactEnabled(hMetaContact, "LogToDisk", AVH_DEF_LOGTOHISTORY)) { TCHAR filename[MAX_PATH] = _T(""); GetOldStyleAvatarName(filename, hMetaContact); if (CopyImageFile(avatar->filename, filename)) ShowPopup(hContact, _T("Avatar History: Unable to save avatar"), filename); else ShowDebugPopup(hContact, _T("AVH Debug: File copied successfully"), filename); } } } } else { // See if we already have the avatar TCHAR hash[128]; lstrcpyn(hash, avatar->hash, sizeof(hash)); ConvertToFilename(hash, sizeof(hash)); TCHAR *file = GetCachedAvatar(proto, hash); if (file != NULL) { lstrcpyn(history_filename, file, MAX_REGS(history_filename)); mir_free(file); } else { if (opts.log_keep_same_folder) GetHistoryFolder(history_filename); else GetProtocolFolder(history_filename, proto); mir_sntprintf(history_filename, MAX_REGS(history_filename), _T("%s\\%s"), history_filename, hash); if (CopyImageFile(avatar->filename, history_filename)) ShowPopup(hContact, _T("Avatar History: Unable to save avatar"), history_filename); else ShowDebugPopup(hContact, _T("AVH Debug: File copied successfully"), history_filename); } if (opts.log_per_contact_folders) { CreateOldStyleShortcut(hContact, history_filename); if (ServiceExists(MS_MC_GETMETACONTACT)) { HANDLE hMetaContact = (HANDLE) CallService(MS_MC_GETMETACONTACT, wParam, 0); if (hMetaContact != NULL && ContactEnabled(hMetaContact, "LogToDisk", AVH_DEF_LOGTOHISTORY)) CreateOldStyleShortcut(hMetaContact, history_filename); } } } } if (ContactEnabled(hContact, "AvatarPopups", AVH_DEF_AVPOPUPS) && opts.popup_show_changed) ShowPopup(hContact, NULL, opts.popup_changed); if (ContactEnabled(hContact, "LogToHistory", AVH_DEF_LOGTOHISTORY)) { TCHAR rel_path[MAX_PATH] = _T(""); CallService(MS_UTILS_PATHTORELATIVET,(WPARAM)history_filename,(LPARAM)rel_path); #ifdef _UNICODE char *blob = mir_utf8encodeT(rel_path); int flags = DBEF_READ | DBEF_UTF; #else char *blob = mir_strdup(rel_path); int flags = DBEF_READ; #endif HistoryEvents_AddToHistoryEx(hContact, EVENTTYPE_AVATAR_CHANGE, 0, NULL, 0, (PBYTE) blob, (int) strlen(blob) + 1, flags); } } return 0; }
void CIrcProto::setTString( HANDLE hContact, const char* name, const TCHAR* value ) { DBWriteContactSettingTString(hContact, m_szModuleName, name, value ); }
static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hw; int sel; DBVARIANT dbv; switch ( msg ) { case WM_INITDIALOG: { TranslateDialogDefault( hwndDlg ); SendMessage(GetDlgItem(hwndDlg, IDC_SPIN1), UDM_SETRANGE, 0, (LPARAM)MAKELONG(50, 5)); if(!DBGetContactSetting(NULL,"WorldTime","FontSize",&dbv) || !DBGetContactSetting(NULL,"CLC","Font0Size",&dbv)) { SendMessage(GetDlgItem(hwndDlg, IDC_SPIN1), UDM_SETPOS, 0, dbv.bVal); } SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 0)); SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_SETPOS, 0, DBGetContactSettingWord(NULL, "WorldTime", "Indent", 0)); SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 6)); SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_SETPOS, 0, DBGetContactSettingWord(NULL, "WorldTime", "RowHeight", GetSystemMetrics(SM_CYSMICON))); copy_listbox_items(temp_listbox_items, listbox_items); hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2); for(int ili = 0; ili < temp_listbox_items.getCount(); ili++) { sel = SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)&temp_listbox_items[ili].pszText); } if(!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { bool minmax = (DBGetContactSettingByte(NULL, "WorldTime", "MinMax", DEFAULT_MINMAX ? 1 : 0) == 1); CheckDlgButton(hwndDlg, IDC_CHK_MINMAX, minmax); bool hide_menu = (DBGetContactSettingByte(NULL, "WorldTime", "HideMenu", 0) == 1); CheckDlgButton(hwndDlg, IDC_CHK_HIDEMENU, hide_menu ? 1 : 0); } else { CheckDlgButton(hwndDlg, IDC_CHK_HIDEMENU, TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_HIDEMENU), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_SHOW), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_MINMAX), FALSE); } bool set_format = (DBGetContactSettingByte(NULL, "WorldTime", "EnableTimeFormat", 0) == 1); CheckDlgButton(hwndDlg, IDC_CHK_FORMAT, set_format ? 1 : 0); bool show_icons = (DBGetContactSettingByte(NULL, "WorldTime", "ShowIcons", 1) == 1); CheckDlgButton(hwndDlg, IDC_CHK_ICONS, show_icons ? 1 : 0); DBVARIANT dbv; if(!DBGetContactSettingTString(NULL, "WorldTime", "TimeFormat", &dbv)) _tcscpy(format_string, dbv.ptszVal); DBFreeVariant(&dbv); SetDlgItemText(hwndDlg, IDC_ED_FORMAT, format_string); if(!DBGetContactSettingTString(NULL, "WorldTime", "DateFormat", &dbv)) _tcscpy(date_format_string, dbv.ptszVal); DBFreeVariant(&dbv); SetDlgItemText(hwndDlg, IDC_ED_DATE_FORMAT, date_format_string); if(!set_format) { hw = GetDlgItem(hwndDlg, IDC_ED_FORMAT); EnableWindow(hw, FALSE); hw = GetDlgItem(hwndDlg, IDC_ED_DATE_FORMAT); EnableWindow(hw, FALSE); } SendDlgItemMessage(hwndDlg, IDC_TEXTCOL, CPM_SETCOLOUR, 0, DBGetContactSettingDword(NULL, "WorldTime", "FontCol", GetSysColor(COLOR_WINDOWTEXT))); SendDlgItemMessage(hwndDlg, IDC_BGCOL, CPM_SETCOLOUR, 0, DBGetContactSettingDword(NULL, "WorldTime", "BgColour", GetSysColor(COLOR_3DFACE))); if(ServiceExists(MS_FONT_REGISTERT)) { ShowWindow(GetDlgItem(hwndDlg, IDC_STATICH), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_STATICH2), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_SPIN1), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_ED_FSIZE), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_TEXTCOL), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_STATFS), SW_SHOW); } //return TRUE; return FALSE; } case WM_COMMAND: if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { switch( LOWORD( wParam )) { case IDC_ED_FORMAT: case IDC_ED_DATE_FORMAT: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } if (HIWORD( wParam ) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LIST_TIMES2) { hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2); sel = SendMessage(hw, LB_GETCURSEL, 0, 0); if(sel != LB_ERR) { hw = GetDlgItem(hwndDlg, IDC_BTN_REM); EnableWindow(hw, sel != -1); hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT); EnableWindow(hw, sel != -1); hw = GetDlgItem(hwndDlg, IDC_BTN_UP); EnableWindow(hw, (sel > 0)); hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2); int count = SendMessage(hw, LB_GETCOUNT, 0, 0); hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN); EnableWindow(hw, (sel < count - 1)); } } if ( HIWORD( wParam ) == BN_CLICKED ) { switch( LOWORD( wParam )) { case IDC_BTN_SHOW: ShowWindow(pluginwind, SW_SHOW); break; case IDC_BTN_EDIT: hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2); sel = SendMessage(hw, LB_GETCURSEL, 0, 0); if(sel != LB_ERR && sel != -1) { add_edit_item = temp_listbox_items[sel]; if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hwndDlg, DlgProcOpts2) == IDOK) { temp_listbox_items[sel] = add_edit_item; SendMessage(hw, LB_DELETESTRING, (WPARAM)sel, (LPARAM)0); SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel, (LPARAM)add_edit_item.pszText); SendMessage(hw, LB_SETCURSEL, (WPARAM)sel, 0); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } } break; case IDC_BTN_ADD: add_edit_item.pszText[0] = '\0'; add_edit_item.timezone_list_index = -1; if(DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG2), hwndDlg, DlgProcOpts2) == IDOK) { temp_listbox_items.insert(new LISTITEM(add_edit_item)); hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2); sel = SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)add_edit_item.pszText); SendMessage(hw, LB_SETCURSEL, (WPARAM)sel, 0); hw = GetDlgItem(hwndDlg, IDC_BTN_REM); EnableWindow(hw, TRUE); hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT); EnableWindow(hw, TRUE); sel = temp_listbox_items.getCount() - 1; hw = GetDlgItem(hwndDlg, IDC_BTN_UP); EnableWindow(hw, (sel > 0)); hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2); int count = SendMessage(hw, LB_GETCOUNT, 0, 0); hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN); EnableWindow(hw, (sel < count - 1)); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } break; case IDC_BTN_REM: hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2); sel = SendMessage(hw, LB_GETCURSEL, 0, 0); if(sel != LB_ERR) { SendMessage(hw, LB_DELETESTRING, (WPARAM)sel, 0); temp_listbox_items.remove(sel); hw = GetDlgItem(hwndDlg, IDC_BTN_REM); EnableWindow(hw, FALSE); hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT); EnableWindow(hw, FALSE); hw = GetDlgItem(hwndDlg, IDC_BTN_UP); EnableWindow(hw, FALSE); hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN); EnableWindow(hw, FALSE); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } break; case IDC_BTN_DOWN: { hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2); int sel2 = SendMessage(hw, LB_GETCURSEL, 0, 0); if(sel2 != LB_ERR) { add_edit_item = temp_listbox_items[sel2]; temp_listbox_items[sel2] = temp_listbox_items[sel2 + 1]; temp_listbox_items[sel2 + 1] = add_edit_item; SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0); SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)temp_listbox_items[sel2].pszText); SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 + 1), (LPARAM)0); SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 + 1), (LPARAM)temp_listbox_items[sel2 + 1].pszText); SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 + 1), 0); hw = GetDlgItem(hwndDlg, IDC_BTN_UP); EnableWindow(hw, (sel2 + 1 > 0)); hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2); int count = SendMessage(hw, LB_GETCOUNT, 0, 0); hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN); EnableWindow(hw, (sel2 + 1 < count - 1)); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } } break; case IDC_BTN_UP: { hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2); int sel2 = SendMessage(hw, LB_GETCURSEL, 0, 0); if(sel2 != LB_ERR) { add_edit_item = temp_listbox_items[sel2]; temp_listbox_items[sel2] = temp_listbox_items[sel2 - 1]; temp_listbox_items[sel2 - 1] = add_edit_item; SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0); SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)temp_listbox_items[sel2].pszText); SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 - 1), (LPARAM)0); SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 - 1), (LPARAM)temp_listbox_items[sel2 - 1].pszText); SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 - 1), 0); hw = GetDlgItem(hwndDlg, IDC_BTN_UP); EnableWindow(hw, (sel2 - 1 > 0)); hw = GetDlgItem(hwndDlg, IDC_LIST_TIMES2); int count = SendMessage(hw, LB_GETCOUNT, 0, 0); hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN); EnableWindow(hw, (sel2 - 1 < count - 1)); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } } break; case IDC_CHK_ICONS: case IDC_CHK_MINMAX: SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); break; case IDC_CHK_HIDEMENU: SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); break; case IDC_CHK_FORMAT: hw = GetDlgItem(hwndDlg, IDC_ED_FORMAT); EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_FORMAT)); hw = GetDlgItem(hwndDlg, IDC_ED_DATE_FORMAT); EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_FORMAT)); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); break; } } if(LOWORD(wParam) == IDC_TEXTCOL || LOWORD(wParam) == IDC_BGCOL || LOWORD(wParam) == IDC_SPIN1 || LOWORD(wParam) == IDC_SP_INDENT || LOWORD(wParam) == IDC_SP_ROWHEIGHT) { SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } break; case WM_NOTIFY: if(((LPNMHDR)lParam)->code == UDN_DELTAPOS ) { SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } if(((LPNMHDR)lParam)->code == PSN_APPLY ) { bool new_minmax = IsDlgButtonChecked(hwndDlg, IDC_CHK_MINMAX) == BST_CHECKED; DBWriteContactSettingByte(NULL, "WorldTime", "MinMax", new_minmax ? 1 : 0); set_minmax(new_minmax); bool new_set_format = IsDlgButtonChecked(hwndDlg, IDC_CHK_FORMAT) == BST_CHECKED; DBWriteContactSettingByte(NULL, "WorldTime", "EnableTimeFormat", new_set_format ? 1 : 0); set_set_format(new_set_format); bool new_show_icons = IsDlgButtonChecked(hwndDlg, IDC_CHK_ICONS) == BST_CHECKED; DBWriteContactSettingByte(NULL, "WorldTime", "ShowIcons", new_show_icons ? 1 : 0); set_show_icons(new_show_icons); bool new_hide_menu = IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEMENU) == BST_CHECKED; DBWriteContactSettingByte(NULL, "WorldTime", "HideMenu", new_hide_menu ? 1 : 0); set_hide_menu(new_hide_menu); TCHAR buf[512]; GetDlgItemText(hwndDlg, IDC_ED_FORMAT, buf, 512); DBWriteContactSettingTString(NULL, "WorldTime", "TimeFormat", buf); set_time_format(buf); GetDlgItemText(hwndDlg, IDC_ED_DATE_FORMAT, buf, 512); DBWriteContactSettingTString(NULL, "WorldTime", "DateFormat", buf); set_date_format(buf); copy_listbox_items(listbox_items, temp_listbox_items); save_listbox_items(); if(!ServiceExists(MS_FONT_REGISTERT)) { DBWriteContactSettingDword(NULL, "WorldTime", "FontCol", ContactFontColour = SendDlgItemMessage(hwndDlg, IDC_TEXTCOL, CPM_GETCOLOUR, 0, 0)); DBWriteContactSettingByte(0, "WorldTime", "FontSize", (BYTE)SendMessage(GetDlgItem(hwndDlg, IDC_SPIN1), UDM_GETPOS, 0, 0) & 255); } DBWriteContactSettingDword(NULL, "WorldTime", "BgColour", SendDlgItemMessage(hwndDlg, IDC_BGCOL, CPM_GETCOLOUR, 0, 0)); DBWriteContactSettingWord(0, "WorldTime", "Indent", (WORD)SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_GETPOS, 0, 0)); DBWriteContactSettingWord(0, "WorldTime", "RowHeight", (WORD)SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_GETPOS, 0, 0)); DeleteObject(ContactFont); ContactFont = (HFONT)GetFont(); if(pluginwind) { /* RECT r; SIZE textSize; GetWindowRect(pluginwind, &r); HFONT hOldFont = (HFONT)SelectObject(GetDC(pluginwind), ContactFont); GetTextExtentPoint32(GetDC(pluginwind),"X",1,&textSize); SelectObject(GetDC(pluginwind), hOldFont); SetWindowPos(pluginwind, 0, 0, 0, r.right - r.left, textSize.cy * listbox_items.size(), SWP_NOZORDER | SWP_NOMOVE); if(Frameid != -1) { CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, (WPARAM)MAKELONG(FO_HEIGHT, Frameid), (LPARAM)DBGetContactSettingByte(0, "WorldTime", "FontSize", 10) * listbox_items.size()); } */ FillList(0, 0); } return TRUE; } break; } return FALSE; }
void RenameUserDefSession(int ses_count,TCHAR* ptszNewName) { char szSession[256]={0}; mir_snprintf(szSession, SIZEOF(szSession), "%s_%u", "UserSessionDsc", ses_count); DBWriteContactSettingTString(NULL, __INTERNAL_NAME, szSession, ptszNewName); }
INT_PTR cfg::writeTString(const HANDLE hContact, const char *szModule = 0, const char *szSetting = 0, const TCHAR *str = 0) { return(DBWriteContactSettingTString(hContact, szModule, szSetting, str)); }
void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening) { // cut message if needed if (opt.LTruncateMsg && (opt.LMsgLen > 0) && xsc->stzText && (_tcslen(xsc->stzText) > opt.LMsgLen)) { TCHAR buff[MAX_TEXT_LEN + 3]; _tcsncpy(buff, xsc->stzText, opt.LMsgLen); buff[opt.LMsgLen] = 0; _tcscat(buff, _T("...")); mir_free(xsc->stzText); xsc->stzText = mir_tstrdup(buff); } TCHAR *Template; switch (xsc->action) { case NOTIFY_NEW_XSTATUS: Template = templates.LogNewXstatus; break; case NOTIFY_NEW_MESSAGE: Template = templates.LogNewMsg; break; case NOTIFY_REMOVE: Template = templates.LogRemove; break; case NOTIFY_OPENING_ML: Template = templates.LogOpening; break; } TCHAR stzLogText[2*MAX_TEXT_LEN]; TCHAR stzLastLog[2*MAX_TEXT_LEN]; ReplaceVars(xsc, Template, templates.LogDelimiter, stzLogText); DBGetStringDefault(xsc->hContact, MODULE, DB_LASTLOG, stzLastLog, SIZEOF(stzLastLog), _T("")); if (!opt.KeepInHistory || !(opt.PreventIdentical && _tcscmp(stzLastLog, stzLogText) == 0)) { DBWriteContactSettingTString(xsc->hContact, MODULE, DB_LASTLOG, stzLogText); char *blob; #ifdef _UNICODE blob = mir_utf8encodeT(stzLogText); #else blob = mir_strdup(stzLogText); #endif DBEVENTINFO dbei = {0}; dbei.cbSize = sizeof(dbei); dbei.cbBlob = (DWORD)strlen(blob) + 1; dbei.pBlob = (PBYTE) blob; dbei.eventType = EVENTTYPE_STATUSCHANGE; dbei.flags = DBEF_READ; #ifdef _UNICODE dbei.flags |= DBEF_UTF; #endif dbei.timestamp = (DWORD)time(NULL); dbei.szModule = xsc->szProto; HANDLE hDBEvent = (HANDLE)CallService(MS_DB_EVENT_ADD, (WPARAM)xsc->hContact, (LPARAM)&dbei); mir_free(blob); if (!opt.KeepInHistory) { DBEVENT *dbevent = (DBEVENT *)mir_alloc(sizeof(DBEVENT)); dbevent->hContact = xsc->hContact; dbevent->hDBEvent = hDBEvent; li.List_Insert(eventList, dbevent, eventList->realCount); } } }
static int RenameGroupWithMove(int groupId,const TCHAR *szName,int move) { char idstr[33]; TCHAR str[256], oldName[256]; DBVARIANT dbv; HANDLE hContact; if(GroupNameExists(szName,groupId)) { MessageBox(NULL,TranslateT("You already have a group with that name. Please enter a unique name for the group."),TranslateT("Rename Group"),MB_OK); return 1; } //do the change itoa(groupId,idstr,10); if (DBGetContactSettingTString(NULL, "CListGroups", idstr, &dbv)) return 1; str[0]=dbv.ptszVal[0]; lstrcpyn(oldName, (TCHAR*)dbv.ptszVal + 1, SIZEOF(oldName)); DBFreeVariant(&dbv); { WORD l; l=lstrlen(szName)+sizeof(TCHAR); l=min(l,SIZEOF(str)); l--; lstrcpyn(str + 1, szName, l); str[l+1]=_T('\0'); } DBWriteContactSettingTString(NULL, "CListGroups", idstr, str); //must rename setting in all child contacts too hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); do { if (DBGetContactSettingTString(hContact, "CList", "Group", &dbv)) continue; if ( _tcscmp(dbv.ptszVal, oldName)) continue; DBWriteContactSettingTString(hContact, "CList", "Group", szName); } while ((hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0)) != NULL); //rename subgroups { TCHAR szNewName[256]; int len,i; len = lstrlen(oldName); for(i=0;;i++) { if (i == groupId) continue; itoa(i,idstr,10); if (DBGetContactSettingTString(NULL, "CListGroups", idstr, &dbv)) break; if ( !_tcsncmp((TCHAR*)dbv.ptszVal + 1, oldName, len) && dbv.ptszVal[len + 1] == _T('\\') && _tcschr((TCHAR*)dbv.ptszVal+len + 2, _T('\\')) == NULL) { mir_sntprintf( szNewName, SIZEOF(szNewName), _T("%s\\%s"), szName,(TCHAR*)dbv.pszVal + len + 2 ); RenameGroupWithMove(i,szNewName,0); //luckily, child groups will never need reordering } DBFreeVariant(&dbv); } } //finally must make sure it's after any parent items if(move) { TCHAR *pszLastBackslash; int i; lstrcpyn(str, szName, SIZEOF(str)); pszLastBackslash = _tcsrchr(str, '\\'); if (pszLastBackslash == NULL) return 0; *pszLastBackslash='\0'; for(i=0;;i++) { itoa(i,idstr,10); if (DBGetContactSettingTString(NULL, "CListGroups", idstr, &dbv)) break; if (!lstrcmp((TCHAR*)dbv.ptszVal + 1, str)) { if (i < groupId) break; //is OK MoveGroupBefore(groupId+1,i+2); break; } DBFreeVariant(&dbv); } } return 0; }
static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); SetDlgItemText(hwndDlg, IDC_ED_UNAME, options.username); SetDlgItemText(hwndDlg, IDC_ED_PW, options.password); SetDlgItemText(hwndDlg, IDC_ED_HOST, options.host); SetDlgItemText(hwndDlg, IDC_ED_CIDNAME, options.cid_name); SetDlgItemText(hwndDlg, IDC_ED_CIDNUM, options.cid_number); SetDlgItemInt(hwndDlg, IDC_ED_PORT, options.port, FALSE); CheckDlgButton(hwndDlg, IDC_CHK_POPDIALIN, options.pop_dial_in ? TRUE : FALSE); CheckDlgButton(hwndDlg, IDC_CHK_POPDIALOUT, options.pop_dial_out ? TRUE : FALSE); CheckDlgButton(hwndDlg, IDC_CHK_MICBOOST, options.mic_boost ? TRUE : FALSE); { iaxc_audio_device *dev; int nDevs, in, out, ring, ind; iaxc_audio_devices_get(&dev, &nDevs, &in, &out, &ring); for(int i = 0; i < nDevs; i++) { if(dev[i].capabilities & IAXC_AD_INPUT) { ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVIN, CB_ADDSTRING, 0, (LPARAM)dev[i].name); SendDlgItemMessage(hwndDlg, IDC_CMB_DEVIN, CB_SETITEMDATA, ind, i); if(i == in) SendDlgItemMessage(hwndDlg, IDC_CMB_DEVIN, CB_SETCURSEL, ind, 0); } if(dev[i].capabilities & IAXC_AD_OUTPUT) { ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVOUT, CB_ADDSTRING, 0, (LPARAM)dev[i].name); SendDlgItemMessage(hwndDlg, IDC_CMB_DEVOUT, CB_SETITEMDATA, ind, i); if(i == out) SendDlgItemMessage(hwndDlg, IDC_CMB_DEVOUT, CB_SETCURSEL, ind, 0); } /* if(dev[i].capabilities & IAXC_AD_RING) { ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVRING, CB_ADDSTRING, 0, (LPARAM)dev[i].name); SendDlgItemMessage(hwndDlg, IDC_CMB_DEVRING, CB_SETITEMDATA, ind, i); if(i == ring) SendDlgItemMessage(hwndDlg, IDC_CMB_DEVRING, CB_SETCURSEL, ind, 0); } */ } } SendDlgItemMessage(hwndDlg, IDC_HK_DLG, HKM_SETHOTKEY, options.dlgHotkey, 0); return FALSE; case WM_COMMAND: if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } if ( HIWORD( wParam ) == CBN_SELCHANGE) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } if ( HIWORD( wParam ) == BN_CLICKED) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: { char buffer[512]; GetDlgItemText(hwndDlg, IDC_ED_UNAME, buffer, 512); if(options.username) free(options.username); options.username = strdup(buffer); GetDlgItemText(hwndDlg, IDC_ED_PW, buffer, 512); if(options.password) free(options.password); options.password = strdup(buffer); GetDlgItemText(hwndDlg, IDC_ED_HOST, buffer, 512); if(options.host) free(options.host); options.host = strdup(buffer); GetDlgItemText(hwndDlg, IDC_ED_CIDNAME, buffer, 512); if(options.cid_name) free(options.cid_name); options.cid_name = strdup(buffer); GetDlgItemText(hwndDlg, IDC_ED_CIDNUM, buffer, 512); if(options.cid_number) free(options.cid_number); options.cid_number = strdup(buffer); DBWriteContactSettingTString(0, MODULE, "Host", options.host); DBWriteContactSettingTString(0, MODULE, "Username", options.username); DBWriteContactSettingTString(0, MODULE, "Password", options.password); DBWriteContactSettingTString(0, MODULE, "CIDName", options.cid_name); DBWriteContactSettingTString(0, MODULE, "CIDNumber", options.cid_number); iaxc_audio_device *dev; int nDevs, in, out, ring, ind; iaxc_audio_devices_get(&dev, &nDevs, &in, &out, &ring); ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVIN, CB_GETCURSEL, 0, 0); in = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVIN, CB_GETITEMDATA, ind, 0); ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVOUT, CB_GETCURSEL, 0, 0); out = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVOUT, CB_GETITEMDATA, ind, 0); //ind = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVRING, CB_GETCURSEL, 0, 0); //ring = SendDlgItemMessage(hwndDlg, IDC_CMB_DEVRING, CB_GETITEMDATA, ind, 0); DBWriteContactSettingTString(0, MODULE, "DeviceIn", dev[in].name); DBWriteContactSettingTString(0, MODULE, "DeviceOut", dev[out].name); //DBWriteContactSettingTString(0, MODULE, "DeviceRing", dev[ring].name); BOOL trans; int port = GetDlgItemInt(hwndDlg, IDC_ED_PORT, &trans, FALSE); if(trans) options.port = port; DBWriteContactSettingDword(0, MODULE, "Port", options.port); iaxc_audio_devices_set(in, out, ring); options.dlgHotkey = (WORD)SendDlgItemMessage(hwndDlg, IDC_HK_DLG, HKM_GETHOTKEY, 0, 0); DBWriteContactSettingWord(0, MODULE, "DlgHotkey", options.dlgHotkey); ResetDlgHotkey(); options.pop_dial_in = IsDlgButtonChecked(hwndDlg, IDC_CHK_POPDIALIN) ? true : false; options.pop_dial_out = IsDlgButtonChecked(hwndDlg, IDC_CHK_POPDIALOUT) ? true : false; DBWriteContactSettingByte(0, MODULE, "PopupDial", options.pop_dial_in ? 1 : 0); DBWriteContactSettingByte(0, MODULE, "PopupDialOut", options.pop_dial_out ? 1 : 0); options.mic_boost = IsDlgButtonChecked(hwndDlg, IDC_CHK_MICBOOST) ? true : false; DBWriteContactSettingByte(0, MODULE, "MicBoost", options.mic_boost ? 1 : 0); iaxc_mic_boost_set(options.mic_boost ? 1 : 0); } return TRUE; } break; } return 0; }
static int DeleteGroup(WPARAM wParam,LPARAM lParam) { int i; char str[33]; DBVARIANT dbv; HANDLE hContact; TCHAR name[256], szNewParent[256], *pszLastBackslash; //get the name itoa(wParam-1,str,10); if (DBGetContactSettingTString(NULL, "CListGroups", str, &dbv)) return 1; if (DBGetContactSettingByte(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT)) if (MessageBox((HWND)CallService(MS_CLUI_GETHWND, 0, 0), TranslateT("Are you sure you want to delete this group? This operation can not be undone."), TranslateT("Delete Group"), MB_YESNO|MB_ICONQUESTION)==IDNO) return 1; lstrcpyn(name, (TCHAR*)dbv.ptszVal + 1, SIZEOF(name)); DBFreeVariant(&dbv); SetCursor(LoadCursor(NULL,IDC_WAIT)); //must remove setting from all child contacts too //children are demoted to the next group up, not deleted. lstrcpy(szNewParent, name); pszLastBackslash = _tcsrchr(szNewParent, '\\'); if (pszLastBackslash) pszLastBackslash[0] = '\0'; else szNewParent[0] = '\0'; hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0); do { if (DBGetContactSettingTString(hContact, "CList", "Group", &dbv)) continue; if (_tcscmp(dbv.ptszVal, name)) { DBFreeVariant(&dbv); continue; } DBFreeVariant(&dbv); if (szNewParent[0]) DBWriteContactSettingTString(hContact, "CList", "Group", szNewParent); else DBDeleteContactSetting(hContact, "CList", "Group"); } while((hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0))!=NULL); //shuffle list of groups up to fill gap for(i=wParam-1;;i++) { itoa(i+1,str,10); if (DBGetContactSettingStringUtf(NULL, "CListGroups", str, &dbv)) break; itoa(i,str,10); DBWriteContactSettingStringUtf(NULL, "CListGroups", str, dbv.pszVal); DBFreeVariant(&dbv); } itoa(i,str,10); DBDeleteContactSetting(NULL,"CListGroups",str); //rename subgroups { TCHAR szNewName[256]; int len; len = lstrlen(name); for(i=0;;i++) { itoa(i,str,10); if (DBGetContactSettingTString(NULL, "CListGroups", str, &dbv)) break; if (!_tcsncmp((TCHAR*)dbv.ptszVal + 1, name, len) && dbv.ptszVal[len + 1] == '\\' && _tcschr(dbv.ptszVal + len + 2, '\\') == NULL) { if (szNewParent[0]) mir_sntprintf(szNewName, SIZEOF(szNewName), _T("%s\\%s"), szNewParent, dbv.ptszVal + len + 2); else lstrcpyn(szNewName, dbv.ptszVal + len + 2, SIZEOF(szNewName)); RenameGroupT((WPARAM)(i + 1), (LPARAM)szNewName); } DBFreeVariant(&dbv); } } SetCursor(LoadCursor(NULL,IDC_ARROW)); LoadContactTree(); return 0; }
static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) { GCEVENT *gce = (GCEVENT*)lParam, save_gce; GCDEST *gcd = NULL, save_gcd; TCHAR* pWnd = NULL; char* pMod = NULL; BOOL bIsHighlighted = FALSE; BOOL bRemoveFlag = FALSE; int iRetVal = GC_EVENT_ERROR; if ( gce == NULL ) return GC_EVENT_ERROR; gcd = gce->pDest; if ( gcd == NULL ) return GC_EVENT_ERROR; if ( gce->cbSize != SIZEOF_STRUCT_GCEVENT_V1 && gce->cbSize != SIZEOF_STRUCT_GCEVENT_V2 ) return GC_EVENT_WRONGVER; if ( !IsEventSupported( gcd->iType ) ) return GC_EVENT_ERROR; EnterCriticalSection(&cs); #if defined( _UNICODE ) if ( !( gce->dwFlags & GC_UNICODE )) { save_gce = *gce; save_gcd = *gce->pDest; gce->pDest->ptszID = a2tf( gce->pDest->ptszID, gce->dwFlags ); gce->ptszUID = a2tf( gce->ptszUID, gce->dwFlags ); gce->ptszNick = a2tf( gce->ptszNick, gce->dwFlags ); gce->ptszStatus = a2tf( gce->ptszStatus, gce->dwFlags ); gce->ptszText = a2tf( gce->ptszText, gce->dwFlags ); gce->ptszUserInfo = a2tf( gce->ptszUserInfo, gce->dwFlags ); } #endif // Do different things according to type of event switch(gcd->iType) { case GC_EVENT_ADDGROUP: { STATUSINFO* si = SM_AddStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszStatus); if ( si && gce->dwItemData) si->hIcon = CopyIcon((HICON)gce->dwItemData); } iRetVal = 0; goto LBL_Exit; case GC_EVENT_CHUID: case GC_EVENT_CHANGESESSIONAME: case GC_EVENT_SETITEMDATA: case GC_EVENT_GETITEMDATA: case GC_EVENT_CONTROL: case GC_EVENT_SETSBTEXT: case GC_EVENT_ACK: case GC_EVENT_SENDMESSAGE : case GC_EVENT_SETSTATUSEX : iRetVal = DoControl(gce, wParam); goto LBL_Exit; case GC_EVENT_SETCONTACTSTATUS: iRetVal = SM_SetContactStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, (WORD)gce->dwItemData ); goto LBL_Exit; case GC_EVENT_TOPIC: { SESSION_INFO* si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if ( si ) { if ( gce->pszText ) { replaceStr( &si->ptszTopic, gce->ptszText); DBWriteContactSettingTString( si->windowData.hContact, si->pszModule , "Topic", RemoveFormatting( si->ptszTopic )); if ( DBGetContactSettingByte( NULL, "Chat", "TopicOnClist", 0 )) DBWriteContactSettingTString( si->windowData.hContact, "CList" , "StatusMsg", RemoveFormatting( si->ptszTopic )); } } break; } case GC_EVENT_ADDSTATUS: SM_GiveStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus ); break; case GC_EVENT_REMOVESTATUS: SM_TakeStatus( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus); break; case GC_EVENT_MESSAGE: case GC_EVENT_ACTION: if ( !gce->bIsMe && gce->pDest->pszID && gce->pszText ) { SESSION_INFO* si = SM_FindSession( gce->pDest->ptszID, gce->pDest->pszModule ); if ( si ) if ( IsHighlighted( si, gce->ptszText )) bIsHighlighted = TRUE; } break; case GC_EVENT_NICK: SM_ChangeNick( gce->pDest->ptszID, gce->pDest->pszModule, gce); break; case GC_EVENT_JOIN: AddUser(gce); break; case GC_EVENT_PART: case GC_EVENT_QUIT: case GC_EVENT_KICK: bRemoveFlag = TRUE; break; } // Decide which window (log) should have the event if ( gcd->pszID ) { pWnd = gcd->ptszID; pMod = gcd->pszModule; } else if ( gcd->iType == GC_EVENT_NOTICE || gcd->iType == GC_EVENT_INFORMATION ) { SESSION_INFO* si = GetActiveSession(); if ( si && !lstrcmpA( si->pszModule, gcd->pszModule )) { pWnd = si->ptszID; pMod = si->pszModule; } else { iRetVal = 0; goto LBL_Exit; } } else { // Send the event to all windows with a user pszUID. Used for broadcasting QUIT etc SM_AddEventToAllMatchingUID( gce ); if ( !bRemoveFlag ) { iRetVal = 0; goto LBL_Exit; } } // add to log if ( pWnd ) { SESSION_INFO* si = SM_FindSession(pWnd, pMod); // fix for IRC's old stuyle mode notifications. Should not affect any other protocol if ((gce->pDest->iType == GC_EVENT_ADDSTATUS || gce->pDest->iType == GC_EVENT_REMOVESTATUS) && !( gce->dwFlags & GCEF_ADDTOLOG )) { iRetVal = 0; goto LBL_Exit; } if (gce && gce->pDest->iType == GC_EVENT_JOIN && gce->time == 0) { iRetVal = 0; goto LBL_Exit; } if (si && (si->bInitDone || gce->pDest->iType == GC_EVENT_TOPIC || (gce->pDest->iType == GC_EVENT_JOIN && gce->bIsMe))) { if (SM_AddEvent(pWnd, pMod, gce, bIsHighlighted) && si->hWnd) { SendMessage(si->hWnd, GC_ADDLOG, 0, 0); } else if (si->hWnd) { SendMessage(si->hWnd, GC_REDRAWLOG2, 0, 0); } DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0); if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.LoggingEnabled) LogToFile(si, gce); } if ( !bRemoveFlag ) { iRetVal = 0; goto LBL_Exit; } } if ( bRemoveFlag ) iRetVal = ( SM_RemoveUser( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID ) == 0 ) ? 1 : 0; LBL_Exit: LeaveCriticalSection(&cs); #if defined( _UNICODE ) if ( !( gce->dwFlags & GC_UNICODE )) { mir_free((void*)gce->ptszText ); mir_free((void*)gce->ptszNick ); mir_free((void*)gce->ptszUID ); mir_free((void*)gce->ptszStatus ); mir_free((void*)gce->ptszUserInfo ); mir_free((void*)gce->pDest->ptszID ); *gce = save_gce; *gce->pDest = save_gcd; } #endif return iRetVal; }
static INT_PTR DoControl(GCEVENT * gce, WPARAM wp) { if ( gce->pDest->iType == GC_EVENT_CONTROL ) { switch (wp) { case WINDOW_HIDDEN: { SESSION_INFO* si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if (si) { si->bInitDone = TRUE; SetActiveSession(si->ptszID, si->pszModule); if (si->hWnd) ShowRoom(si, wp, FALSE); } } return 0; case WINDOW_MINIMIZE: case WINDOW_MAXIMIZE: case WINDOW_VISIBLE: case SESSION_INITDONE: { SESSION_INFO* si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if (si) { si->bInitDone = TRUE; if (wp != SESSION_INITDONE || DBGetContactSettingByte(NULL, "Chat", "PopupOnJoin", 0) == 0) ShowRoom(si, wp, TRUE); return 0; } } break; case SESSION_OFFLINE: SM_SetOffline(gce->pDest->ptszID, gce->pDest->pszModule); // fall through case SESSION_ONLINE: SM_SetStatus( gce->pDest->ptszID, gce->pDest->pszModule, wp==SESSION_ONLINE?ID_STATUS_ONLINE:ID_STATUS_OFFLINE); break; case WINDOW_CLEARLOG: { SESSION_INFO* si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if ( si ) { LM_RemoveAll(&si->pLog, &si->pLogEnd); si->iEventCount = 0; si->LastTime = 0; } break; } case SESSION_TERMINATE: return SM_RemoveSession(gce->pDest->ptszID, gce->pDest->pszModule); } SM_SendMessage(gce->pDest->ptszID, gce->pDest->pszModule, GC_EVENT_CONTROL + WM_USER + 500, wp, 0); } else if (gce->pDest->iType == GC_EVENT_CHUID && gce->pszText) { SM_ChangeUID( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszNick, gce->ptszText); } else if (gce->pDest->iType == GC_EVENT_CHANGESESSIONAME && gce->pszText) { SESSION_INFO* si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if ( si ) { replaceStr( &si->ptszName, gce->ptszText ); if (si->hWnd) SendMessage(si->hWnd, DM_UPDATETITLEBAR, 0, 0); } } else if (gce->pDest->iType == GC_EVENT_SETITEMDATA) { SESSION_INFO* si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if (si) si->dwItemData = gce->dwItemData; } else if (gce->pDest->iType ==GC_EVENT_GETITEMDATA) { SESSION_INFO* si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if (si) { gce->dwItemData = si->dwItemData; return si->dwItemData; } return 0; } else if (gce->pDest->iType ==GC_EVENT_SETSBTEXT) { SESSION_INFO* si = SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); if (si) { replaceStr( &si->ptszStatusbarText, gce->ptszText ); if ( si->ptszStatusbarText ) DBWriteContactSettingTString(si->windowData.hContact, si->pszModule, "StatusBar", si->ptszStatusbarText); else DBWriteContactSettingString(si->windowData.hContact, si->pszModule, "StatusBar", ""); if (si->hWnd) { SendMessage(si->hWnd, DM_UPDATESTATUSBAR, 0, 0); } } } else if (gce->pDest->iType == GC_EVENT_ACK) { SM_SendMessage(gce->pDest->ptszID, gce->pDest->pszModule, GC_ACKMESSAGE, 0, 0); } else if (gce->pDest->iType == GC_EVENT_SENDMESSAGE && gce->pszText) { SM_SendUserMessage( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszText); } else if (gce->pDest->iType == GC_EVENT_SETSTATUSEX) { SM_SetStatusEx( gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszText, gce->dwItemData); } else return 1; return 0; }
static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) { MODULEINFO* mi; GCSESSION *gcw =(GCSESSION *)lParam; if (gcw== NULL) return GC_NEWSESSION_ERROR; if (gcw->cbSize != SIZEOF_STRUCT_GCWINDOW_V1) return GC_NEWSESSION_WRONGVER; EnterCriticalSection(&cs); if (( mi = MM_FindModule( gcw->pszModule )) != NULL ) { TCHAR* ptszID = a2tf( gcw->ptszID, gcw->dwFlags ); SESSION_INFO* si = SM_AddSession( ptszID, gcw->pszModule); if (mi->hOfflineIcon == NULL) { LoadModuleIcons(mi); } // create a new session and set the defaults if ( si != NULL ) { TCHAR szTemp[256]; si->dwItemData = gcw->dwItemData; if ( gcw->iType != GCW_SERVER ) si->wStatus = ID_STATUS_ONLINE; si->iType = gcw->iType; si->dwFlags = gcw->dwFlags; si->ptszName = a2tf( gcw->ptszName, gcw->dwFlags ); si->ptszStatusbarText = a2tf( gcw->ptszStatusbarText, gcw->dwFlags ); si->iSplitterX = g_Settings.iSplitterX; si->iSplitterY = g_Settings.iSplitterY; si->iLogFilterFlags = (int)DBGetContactSettingDword(NULL, "Chat", "FilterFlags", 0x03E0); si->bFilterEnabled = DBGetContactSettingByte(NULL, "Chat", "FilterEnabled", 0); si->bNicklistEnabled = DBGetContactSettingByte(NULL, "Chat", "ShowNicklist", 1); #if defined( _UNICODE ) if ( !( gcw->dwFlags & GC_UNICODE )) { si->pszID = mir_strdup( gcw->pszID ); si->pszName = mir_strdup( gcw->pszName ); } #endif if ( mi->bColor ) { si->iFG = 4; si->bFGSet = TRUE; } if ( mi->bBkgColor ) { si->iBG = 2; si->bBGSet = TRUE; } if (si->iType == GCW_SERVER) mir_sntprintf(szTemp, SIZEOF(szTemp), _T("Server: %s"), si->ptszName); else mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%s"), si->ptszName); si->windowData.hContact = CList_AddRoom( gcw->pszModule, ptszID, szTemp, si->iType); si->windowData.codePage = DBGetContactSettingWord(si->windowData.hContact, si->pszModule, "CodePage", (WORD) CP_ACP); si->pszHeader = Log_CreateRtfHeader(mi, si); DBWriteContactSettingString(si->windowData.hContact, si->pszModule , "Topic", ""); DBDeleteContactSetting(si->windowData.hContact, "CList", "StatusMsg"); if (si->ptszStatusbarText) DBWriteContactSettingTString(si->windowData.hContact, si->pszModule, "StatusBar", si->ptszStatusbarText); else DBWriteContactSettingString(si->windowData.hContact, si->pszModule, "StatusBar", ""); } else { SESSION_INFO* si2 = SM_FindSession( ptszID, gcw->pszModule ); if ( si2 ) { UM_RemoveAll(&si2->pUsers); TM_RemoveAll(&si2->pStatuses); si2->iStatusCount = 0; si2->nUsersInNicklist = 0; if (si2->hWnd ) RedrawWindow(GetDlgItem(si2->hWnd, IDC_CHAT_LIST), NULL, NULL, RDW_INVALIDATE); } } LeaveCriticalSection(&cs); mir_free( ptszID ); return 0; } LeaveCriticalSection(&cs); return GC_NEWSESSION_ERROR; }
int LoadSkinIcons(void) { SKINICONDESC sid; int i, j = 0; char iconName[MAX_PATH], moduleName[MAX_PATH]; TCHAR modulePath[MAX_PATH]; DBVARIANT dbv; // // Perform "1st-time running import" for ( i = 0; i < SIZEOF(mainIcons); i++ ) { _itoa( mainIcons[i].id, moduleName, 10 ); if ( DBGetContactSettingTString( NULL, "Icons", moduleName, &dbv )) break; mir_snprintf( iconName, SIZEOF(iconName), "%s%d", mainIconsFmt, i ); DBWriteContactSettingTString( NULL, "SkinIcons", iconName, dbv.ptszVal ); DBFreeVariant( &dbv ); DBDeleteContactSetting( NULL, "Icons", moduleName ); } for ( ;; ) { // get the next protocol name moduleName[0] = 'p'; moduleName[1] = 0; _itoa( j++, moduleName+1, 100 ); if ( DBGetContactSettingTString( NULL, "Icons", moduleName, &dbv )) break; DBDeleteContactSetting( NULL, "Icons", moduleName ); // make old skinicons' prefix mir_snprintf( moduleName, SIZEOF(moduleName), TCHAR_STR_PARAM, dbv.ptszVal ); // make IcoLib's prefix mir_snprintf( iconName, SIZEOF(iconName), "%s" TCHAR_STR_PARAM, statusIconsFmt, dbv.ptszVal ); convertOneProtocol( moduleName, iconName ); DBFreeVariant( &dbv ); } moduleName[0] = 0; strcpy(iconName, "core_status_" GLOBAL_PROTO_NAME); convertOneProtocol( moduleName, iconName ); CreateServiceFunction( MS_SKIN_LOADICON, sttLoadSkinIcon ); CreateServiceFunction( MS_SKIN_LOADPROTOICON, sttLoadSkinProtoIcon ); CreateServiceFunction( MS_SKIN_LOADPROTOICONBIG, sttLoadSkinProtoIconBig ); ZeroMemory( &sid, sizeof(sid) ); sid.cbSize = sizeof(sid); GetModuleFileName(NULL, modulePath, SIZEOF(modulePath)); sid.ptszDefaultFile = modulePath; sid.flags = SIDF_PATH_TCHAR; sid.pszName = iconName; // // Add main icons to list // for ( i = 0; i < SIZEOF(mainIcons); i++ ) { mir_snprintf( iconName, SIZEOF(iconName), "%s%d", mainIconsFmt, i ); sid.pszSection = mainIcons[i].section == NULL ? "Main Icons" : (char*)mainIcons[i].section; sid.pszDescription = (char*)mainIcons[i].description; sid.iDefaultIndex = mainIcons[i].resource_id; hMainIcons[i] = IcoLib_AddNewIcon( &sid ); } // // Add global icons to list // sid.pszSection = PROTOCOLS_PREFIX "Global"; // // Asterisk is used, to avoid conflict with proto-plugins // 'coz users can't rename it to name with '*' for ( i = 0; i < SIZEOF(statusIcons); i++ ) { mir_snprintf( iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, i ); sid.pszName = iconName; sid.pszDescription = (char*)statusIcons[i].description; sid.iDefaultIndex = statusIcons[i].resource_id; hStatusIcons[i] = IcoLib_AddNewIcon( &sid ); } return 0; }