Juan F. Codagnone wrote: >licq_interests.diff is a first attemp to check for the Users 's personal >interests >i know that the right thing (...) would be to store the array of interests >in this first patch my aproach is to "render" the string. > >qt_interests.diff is my aproach to add it to the Users Info Dialog.. Note >that it display de info in About dialog. (and i don't know yet why) >(i am not a c++ programer) > >Feel free to test, fix, and comment. > >The main thing. Store the array as >Eg: >interests_n = 3 >interests_sz_1 = C, AWK ... >Interests_cat_1 = 68000 >.... >? >So...do you think i should change this code to save the array? > >Regards, > Juan. > > > >------------------------------------------------------------------------ > >? licqd_personal.diff >Index: include/licq_events.h >=================================================================== >RCS file: /cvsroot/licq/licq/include/licq_events.h,v >retrieving revision 1.13 >diff -u -1 -b -p -r1.13 licq_events.h >--- include/licq_events.h 1 Dec 2001 15:50:40 -0000 1.13 >+++ include/licq_events.h 16 Apr 2002 22:04:06 -0000 >@@ -292,2 +292,3 @@ const unsigned long USER_ABOUT > const unsigned long USER_SECURITY = 9; >+const unsigned long USER_INTERESTS = 10; > >Index: include/licq_user.h >=================================================================== >RCS file: /cvsroot/licq/licq/include/licq_user.h,v >retrieving revision 1.23 >diff -u -1 -b -p -r1.23 licq_user.h >--- include/licq_user.h 20 Mar 2002 06:35:46 -0000 1.23 >+++ include/licq_user.h 16 Apr 2002 22:04:06 -0000 >@@ -163,2 +163,3 @@ public: > void SaveAboutInfo(); >+ void SaveInterestsInfo(); > void SaveExtInfo(); >@@ -212,2 +213,3 @@ public: > char *GetAbout() { return m_szAbout; } >+ char *GetInterests() { return m_szInterests; } > >@@ -294,3 +296,4 @@ public: > void SetAbout(const char *n) { SetString(&m_szAbout, n); SaveAboutInfo(); > } >- >+ // Personal Interets Info >+ void SetInterests( const char *n) { SetString(&m_szInterests,n); >SaveInterestsInfo(); } > // Licq Info >@@ -416,2 +419,3 @@ protected: > void LoadAboutInfo(); >+ void LoadInterestsInfo(); > void LoadLicqInfo(); >@@ -505,2 +509,4 @@ protected: > char *m_szAbout; >+ // Personal Interests >+ char *m_szInterests; > >Index: src/icqd-srv.cpp >=================================================================== >RCS file: /cvsroot/licq/licq/src/icqd-srv.cpp,v >retrieving revision 1.29 >diff -u -1 -b -p -r1.29 icqd-srv.cpp >--- src/icqd-srv.cpp 9 Apr 2002 20:58:59 -0000 1.29 >+++ src/icqd-srv.cpp 16 Apr 2002 22:04:07 -0000 >@@ -1125,2 +1125,24 @@ void CICQDaemon::ProcessLocationFam(cons > >+static const char * info_category2str( unsigned short cat ) >+{ struct _table >+ { unsigned short cat ; >+ const char * str ; >+ } ; >+ static struct _table t[] = >+ { >+ { 0x0068, "Computer" } >+ }; >+ unsigned i; >+ const char *ret = "unknown"; >+ >+ for( i=0 ; i < sizeof(t)/sizeof(*t) ; i++ ) >+ { if( cat == t[i].cat ) >+ { ret = t[i].str; >+ break; >+ } >+ } >+ >+ return ret; >+} >+ > //--------ProcessBuddyFam-------------------------------------------------- >@@ -2446,8 +2468,39 @@ void CICQDaemon::ProcessVariousFam(CBuff > // personal interests info >+ unsigned int n_info; >+ unsigned short category; >+ char s[MAX_DATA_LEN]={0}; >+ char *tmp; >+ const char *szCat; >+ int len=sizeof(s); >+ #define sz_sep ": " >+ >+ gLog.Info("%sPersonal Interests Info on %s (%ld).\n", L_SRVxSTR, >+ u->GetAlias(), u ->Uin()); >+ >+ n_info = msg.UnpackChar() ; >+ for ( ; n_info > 0 ; n_info -- ) >+ { /* To do less work i save the interests as only one >+ * string. (versus Interests1,...,InterestsN,ICat1..ICatN) >+ */ >+ >+ category=msg.UnpackUnsignedShort(); >+ tmp = msg.UnpackString(); >+ szCat = info_category2str(category); >+ >+ len -= strlen(tmp) + strlen(sz_sep) + strlen(szCat) + 1 ; >+ if( len > 0 ) >+ { strcat(s,szCat); >+ strcat(s,sz_sep); >+ strcat(s,tmp); >+ strcat(s,"\n"); >+ } >+ else >+ break; >+ delete tmp; >+ } > >- char * buf; >- >- gLog.Unknown("%spersonal interests: %04hx\n%s\n", L_UNKNOWNxSTR, >- nSubSequence, packet.print(buf)); >- delete [] buf; >+ // save the user infomation >+ u->SetInterests( s ); >+ u->SetEnableSave(true); >+ u->SaveInterestsInfo(); > >@@ -2456,2 +2509,4 @@ void CICQDaemon::ProcessVariousFam(CBuff > >+ PushPluginSignal(new CICQSignal(SIGNAL_UPDATExUSER, USER_INTERESTS, >+ u->Uin())); > break; >Index: src/user.cpp >=================================================================== >RCS file: /cvsroot/licq/licq/src/user.cpp,v >retrieving revision 1.36 >diff -u -1 -b -p -r1.36 user.cpp >--- src/user.cpp 19 Mar 2002 06:54:24 -0000 1.36 >+++ src/user.cpp 16 Apr 2002 22:04:08 -0000 >@@ -795,2 +795,3 @@ bool ICQUser::LoadInfo() > LoadAboutInfo(); >+ LoadInterestsInfo(); > LoadLicqInfo(); >@@ -871,2 +872,11 @@ void ICQUser::LoadAboutInfo() > >+//-----ICQUser::LoadInterestsInfo----------------------------------------------- >+void ICQUser::LoadInterestsInfo() >+{ >+ // read in the fields, checking for errors each timei >+ char szTemp[MAX_DATA_LEN]; >+ m_fConf.SetSection("user"); >+ m_fConf.ReadStr("Interests", szTemp, ""); SetAbout(szTemp); >+ >+} > //-----ICQUser::LoadLicqInfo------------------------------------------------- >@@ -999,2 +1009,4 @@ ICQUser::~ICQUser() > free( m_szAbout ); >+ if( m_szInterests ) >+ free( m_szInterests ); > if ( m_szCustomAutoResponse ) >@@ -1089,2 +1101,4 @@ void ICQUser::Init(unsigned long _nUin) > m_szAbout = NULL; >+ // Personal Interests >+ m_szInterests = NULL; > >@@ -1156,2 +1170,3 @@ void ICQUser::SetDefaults() > SetAbout(szTemp); >+ SetInterests(szTemp); > SetCustomAutoResponse(szTemp); >@@ -1847,2 +1862,25 @@ void ICQUser::SaveAboutInfo() > >+//-----ICQUser::SaveInterestsInfo--------------------------------------------- >+void ICQUser::SaveInterestsInfo() >+{ >+ if (!EnableSave()) return; >+ >+ if (!m_fConf.ReloadFile()) >+ { gLog.Error("%sError opening '%s' for reading.\n" >+ "%sSee log for details.\n", >+ L_ERRORxSTR, m_fConf.FileName(), L_BLANKxSTR); >+ return ; >+ } >+ >+ m_fConf.SetSection("user"); >+ m_fConf.WriteStr("Interests", m_szInterests); >+ >+ if (!m_fConf.FlushFile()) >+ { gLog.Error("%sError opening '%s' for writing.\n" >+ "%sSee log for details.\n", L_ERRORxSTR, >+ m_fConf.FileName(), L_BLANKxSTR); >+ >+ return; >+ } >+} > > > >------------------------------------------------------------------------ > >Index: userinfodlg.cpp >=================================================================== >RCS file: /cvsroot/licq/qt-gui/src/userinfodlg.cpp,v >retrieving revision 1.39 >diff -u -1 -b -p -r1.39 userinfodlg.cpp >--- userinfodlg.cpp 8 Apr 2002 16:12:56 -0000 1.39 >+++ userinfodlg.cpp 16 Apr 2002 22:03:13 -0000 >@@ -71,2 +71,3 @@ UserInfoDlg::UserInfoDlg(CICQDaemon *s, > CreateAbout(); >+ CreateInterests(); > CreateHistory(); >@@ -83,2 +84,3 @@ UserInfoDlg::UserInfoDlg(CICQDaemon *s, > tabs->addTab(tabList[AboutInfo].tab, tabList[AboutInfo].label); >+ tabs->addTab(tabList[InterestsInfo].tab, tabList[InterestsInfo].label); > tabs->addTab(tabList[HistoryInfo].tab, tabList[HistoryInfo].label); >@@ -801,3 +803,3 @@ void UserInfoDlg::SetAbout(ICQUser *u) > mleAbout->setText(aboutstr); >- >+ cout << aboutstr ; > if (bDropUser) gUserManager.DropUser(u); >@@ -816,2 +818,53 @@ void UserInfoDlg::SaveAbout() > >+// ----Personal Interests-------------------------------------------------- >+void UserInfoDlg::CreateInterests() >+{ >+ tabList[InterestsInfo].label = tr("&Interests"); >+ tabList[InterestsInfo].tab = new QVBox(this, >tabList[InterestsInfo].label.latin1()); >+ tabList[InterestsInfo].loaded = false; >+ >+ QVBox *p = (QVBox *)tabList[InterestsInfo].tab; >+ >+ p->setMargin(8); >+ p->setSpacing(8); >+ >+ lblInterests = new QLabel(tr("Interests:"), p); >+ mleInterests = new MLEditWrap(true, p); >+ mleInterests->setReadOnly(!m_bOwner); >+ >+} >+ >+void UserInfoDlg::SetInterests(ICQUser *u) >+{ >+ tabList[InterestsInfo].loaded = true; >+ bool bDropUser = false; >+ >+ if (u == NULL) >+ { >+ u = gUserManager.FetchUser(m_nUin, LOCK_R); >+ if (u == NULL) return; >+ bDropUser = true; >+ } >+ >+ QTextCodec * codec = UserCodec::codecForICQUser(u); >+ >+ QString intereststr = codec->toUnicode(u->GetInterests()); >+ intereststr.replace(QRegExp("\r"), ""); >+ mleInterests->setText(intereststr); >+ >+ if (bDropUser) gUserManager.DropUser(u); >+ >+} >+ >+void UserInfoDlg::SaveInterests() >+{ >+ ICQUser *u = gUserManager.FetchUser(m_nUin, LOCK_W); >+ if (u == NULL) return; >+ >+ QTextCodec * codec = UserCodec::codecForICQUser(u); >+ >+ u->SetInterests(codec->fromUnicode(mleInterests->text())); >+ gUserManager.DropUser(u); >+} >+ > //-----LastCounters-------------------------------------------------------- >@@ -1194,2 +1247,3 @@ void UserInfoDlg::updateTab(const QStrin > { >+ cout << txt; > if (txt == tabList[GeneralInfo].label) >@@ -1234,2 +1288,12 @@ void UserInfoDlg::updateTab(const QStrin > } >+ else if( txt == tabList[InterestsInfo].label) >+ { >+ btnMain3->setText(tr("&Update")); >+ btnMain2->setText(m_bOwner ? tr("Retrieve") : tr("&Save")); >+ btnMain3->setEnabled(true); >+ btnMain2->setEnabled(true); >+ currentTab = InterestsInfo; >+ if (!tabList[InterestsInfo].loaded) >+ SetInterests(NULL); >+ } > else if (txt == tabList[HistoryInfo].label) >@@ -1276,2 +1340,5 @@ void UserInfoDlg::SaveSettings() > break; >+ case InterestsInfo: >+ SaveInterests(); >+ break; > case HistoryInfo: >@@ -1314,2 +1381,3 @@ void UserInfoDlg::slotRetrieve() > case AboutInfo: icqEventTag = server->icqRequestMetaInfo(m_nUin); break; >+ case InterestsInfo: icqEventTag = server->icqRequestMetaInfo(m_nUin); break; > } >@@ -1397,2 +1465,3 @@ void UserInfoDlg::slotUpdate() > case AboutInfo: icqEventTag = >server->icqSetAbout(codec->fromUnicode(mleAbout->text())); break; >+ // case InterestsInfo: icqEventTag = >server->icqSetInterests(codec->fromUnicode(mleInterests->text()));break > case HistoryInfo: ShowHistoryNext(); break; >@@ -1469,2 +1538,5 @@ void UserInfoDlg::updatedUser(CICQSignal > SetAbout(u); >+ break; >+ case USER_INTERESTS: >+ SetInterests(u); > break; >Index: userinfodlg.h >=================================================================== >RCS file: /cvsroot/licq/qt-gui/src/userinfodlg.h,v >retrieving revision 1.16 >diff -u -1 -b -p -r1.16 userinfodlg.h >--- userinfodlg.h 5 Mar 2002 17:32:04 -0000 1.16 >+++ userinfodlg.h 16 Apr 2002 22:03:13 -0000 >@@ -52,2 +52,3 @@ public: > AboutInfo, >+ InterestsInfo, > HistoryInfo, >@@ -114,2 +115,7 @@ protected: > >+ // Interests >+ void CreateInterests(); >+ QLabel *lblInterests; >+ MLEditWrap *mleInterests; >+ > // Last Counters >@@ -139,2 +145,3 @@ protected: > void SetAbout(ICQUser *); >+ void SetInterests(ICQUser *); > void SetLastCountersInfo(ICQUser *); >@@ -144,2 +151,3 @@ protected: > void SaveAbout(); >+ void SaveInterests(); > > > I tried patch and interest shows like this :
unknown: BMW,Car Racing - Formula 1 ,Ferrari,Porsche unknown: Action Movies,Horror Movies unknown: Clubs,Dj's,Drinks,Music,parties,Trance Want to make it better? _______________________________________________ Licq-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/licq-devel