hi
here is a patch for newapi. If you apply this you can log into the rms
plugin with username and password while using msn protocol plugin. It
all compiles fine.
What I did:
- correcting some bugs
- introducing FetchOwner and DropOwner with user name and protocol name
as parameter.
- rewriting CLicqDaemon::ProtoPluginList for newapi
- adding two new variables m_szOwnerId, m_szOwnerProtoName in
CRMSClient. This is needed to remember the owner which is logged in the rms.
Please look at the patch and give me some feedback.
regards,
rsLeo
--- svn_newapi//licq/include/licq_icqd.h 2006-11-21 09:50:28.000000000
+0100
+++ newapi/licq/include/licq_icqd.h 2006-11-24 12:25:06.000000000 +0100
@@ -29,8 +29,7 @@
#include "licq_plugin.h"
#include "licq_pluginmanager.h"
-//FIXME NEWAPI To Delete
-#include "../src/licq.h"
+#include "licq_protoplugind.h"
#include <boost/shared_ptr.hpp>
#include <boost/dynamic_property_map.hpp>
@@ -550,7 +549,7 @@
bool PluginLoad(const char *, int, char **);
- void ProtoPluginList(ProtocolPluginsList &);
+ void ProtoPluginList(std::vector<SPluginDataPtr> &lPlugins);
void ProtoPluginShutdown(unsigned short);
bool ProtoPluginLoad(const char *);
int RegisterProtoPlugin();
--- svn_newapi//licq/include/licq_user.h 2006-11-21 09:50:28.000000000
+0100
+++ newapi/licq/include/licq_user.h 2006-11-30 13:23:28.000000000 +0100
@@ -1050,7 +1050,9 @@
void RemoveOwner(unsigned long);
CLicqUser *FetchUser(const char *, unsigned long, unsigned short);
ICQOwner *FetchOwner(unsigned long, unsigned short);
+ ICQOwner *FetchOwner(std::string, std::string, unsigned short);
void DropOwner(unsigned long);
+ void DropOwner(std::string, std::string);
bool IsOnList(const char *, unsigned long);
ICQOwner *FindOwner(const char *, unsigned long);
--- svn_newapi//licq/include/licq_protocolplugin.h 2006-11-21
09:50:28.000000000 +0100
+++ newapi/licq/include/licq_protocolplugin.h 2006-11-30 15:00:23.000000000
+0100
@@ -33,6 +33,8 @@
void setOwner(const std::string &s) { m_Owner = s; }
std::string getOwner() const { return m_Owner; }
+ static unsigned long Name2Ppid(std::string protoName);
+
protected:
CProtocolPlugin(class CLicqDaemon& daemon);
--- svn_newapi//licq/include/Makefile.am 2006-11-21 09:50:28.000000000
+0100
+++ newapi/licq/include/Makefile.am 2006-11-24 12:36:27.000000000 +0100
@@ -13,5 +13,5 @@
licq_plugind.h licq_color.h licq_protoplugin.h \
licq_protoplugind.h licq_homepagecodes.h licq_occupationcodes.h \
licq_interestcodes.h licq_providers.h licq_organizationcodes.h \
- licq_backgroundcodes.h
-
+ licq_backgroundcodes.h licq_callback.h licq_pluginmanager.h \
+ licq_generalplugin.h licq_protocolplugin.h
--- svn_newapi//licq/src/icqd.cpp 2006-11-21 09:50:53.000000000 +0100
+++ newapi/licq/src/icqd.cpp 2006-11-24 10:04:49.000000000 +0100
@@ -42,6 +42,7 @@
#include "support.h"
#include "licq_pluginmanager.h"
#include "licq_protocolplugin.h"
+#include "licq_generalplugin.h"
//#include "licq_callback.h"
#include "licq_icqd.h"
@@ -587,12 +588,9 @@
return true;
}
-void CLicqDaemon::ProtoPluginList(ProtocolPluginsList &lPlugins)
+void CLicqDaemon::ProtoPluginList(std::vector<SPluginDataPtr> &lPlugins)
{
- lPlugins.erase(lPlugins.begin(), lPlugins.end());
- pthread_mutex_lock(&licq->mutex_protoplugins);
- lPlugins = licq->list_protoplugins;
- pthread_mutex_unlock(&licq->mutex_protoplugins);
+ lPlugins = m_pPluginManager->getPluginsData(PLUGIN_PROTOCOL);
}
bool CLicqDaemon::ProtoPluginLoad(const char *szPlugin)
--- svn_newapi//licq/src/user.cpp 2006-11-21 09:50:53.000000000 +0100
+++ newapi/licq/src/user.cpp 2006-11-30 16:22:35.000000000 +0100
@@ -39,6 +39,7 @@
#include "licq_socket.h"
#include "support.h"
#include "pthread_rdwr.h"
+#include "licq_protocolplugin.h" //need for CProtocolPlugin::Name2Ppid
using std::vector;
@@ -1146,8 +1147,11 @@
unsigned short nOwnerPDINFO;
ICQOwner *o = gUserManager.FetchOwner(LICQ_PPID, LOCK_R);
- nOwnerPDINFO = o->GetPDINFO();
- gUserManager.DropOwner(LICQ_PPID);
+ if (o != NULL)
+ {
+ nOwnerPDINFO = o->GetPDINFO();
+ gUserManager.DropOwner(LICQ_PPID);
+ }
// Generate a SID
srand(time(NULL));
@@ -1243,6 +1247,15 @@
return FetchOwner(LICQ_PPID, _nLockType);
}
+ICQOwner *CUserManager::FetchOwner(std::string _szOwnerId,
+ std::string _szProtoName,
+ unsigned short _nLockType)
+{
+ //FIXME NEWAPI
+ //fetch owner with parameters (ownerid,protoname)
+ return FetchOwner(CProtocolPlugin::Name2Ppid(_szProtoName), _nLockType);
+}
+
ICQOwner *CUserManager::FetchOwner(unsigned long _nPPID,
unsigned short _nLockType)
{
@@ -1272,6 +1285,14 @@
DropOwner(LICQ_PPID);
}
+void CUserManager::DropOwner(std::string _szOwnerId,
+ std::string _szProtoName)
+{
+ //FIXME NEWAPI
+ //drow owner with parameters (ownerid,protoname)
+ DropOwner(CProtocolPlugin::Name2Ppid(_szProtoName));
+}
+
void CUserManager::DropOwner(unsigned long _nPPID)
{
LockOwnerList(LOCK_R);
@@ -2867,8 +2888,10 @@
break;
case 'P':
{
- ProtocolPluginsList pl;
- ProtocolPluginsListIter it;
+ //FIXME NEWAPI
+#if 0
+ ProtoPluginsList pl;
+ ProtoPluginsListIter it;
gLicqDaemon->ProtoPluginList(pl);
for (it = pl.begin(); it != pl.end(); it++)
{
@@ -2880,6 +2903,7 @@
// break;
//}
}
+#endif
break;
}
case 'e':
--- svn_newapi//licq/src/protocolplugin.cpp 2006-11-21 09:50:53.000000000
+0100
+++ newapi/licq/src/protocolplugin.cpp 2006-11-30 15:57:38.000000000 +0100
@@ -45,3 +45,18 @@
CProtocolPlugin::~CProtocolPlugin()
{
}
+
+//FIXME NEWAPI
+//We need this function because many parts of the old code use
+//PPIDs. (eg. to identfiy an owner)
+//It helps making old and new code compatible.
+//If newapi is finished this function should be deleted.
+unsigned long CProtocolPlugin::Name2Ppid(std::string protoName)
+{
+ if (protoName == "MSN" || protoName == "msn")
+ return 0x4D534E5F;
+ else
+ return 0x4C696371; //LICQ_PPID;
+}
+
+
--- svn_newapi//rms/src/rms.h 2006-11-21 09:48:02.000000000 +0100
+++ newapi/rms/src/rms.h 2006-11-30 12:56:29.000000000 +0100
@@ -122,6 +122,9 @@
char *m_szEventId;
unsigned long m_nEventPPID;
+ std::string m_szOwnerId;
+ std::string m_szOwnerProtoName;
+
int StateMachine();
int ProcessCommand();
bool ProcessEvent(ICQEvent *);
--- svn_newapi//rms/src/rms.cpp 2006-11-21 09:48:02.000000000 +0100
+++ newapi/rms/src/rms.cpp 2006-11-30 19:26:37.000000000 +0100
@@ -22,8 +22,10 @@
#include "licq_user.h"
#include "licq_constants.h"
#include "licq_callback.h"
+#include "licq_protoplugind.h"
+#include "licq_protocolplugin.h"
-//CLicqRMS *licqRMS = NULL;
+CLicqRMS *licqRMS = NULL;
//static CLicqDaemon *m_daemon = NULL;
const char L_RMSxSTR[] = "[RMS] ";
@@ -148,6 +150,8 @@
CLicqRMS::CLicqRMS(CLicqDaemon &daemon)
: CGeneralPlugin(daemon)
{
+ log = NULL;
+ licqRMS = this;
}
bool CLicqRMS::initialize(int argc, char** argv)
@@ -252,7 +256,8 @@
fd_set f;
int l;
int nResult;
-
+ m_bExit = false;
+
while (!m_bExit)
{
f = CRMSClient::sockman.SocketSet();
@@ -324,7 +329,9 @@
void CLicqRMS::ProcessPipe()
{
char buf[16];
- //read(m_nPipe, buf, 1);
+ //FIXME NEWAPI
+#if 0
+ read(m_nPipe, buf, 1);
switch (buf[0])
{
case 'S': // A signal is pending
@@ -365,6 +372,7 @@
default:
gLog.Warn("%sUnknown notification type from daemon: %c.\n", L_WARNxSTR,
buf[0]);
}
+#endif
}
@@ -717,6 +725,7 @@
case STATE_UIN:
{
m_szCheckId = data_line ? strdup(data_line) : 0;
+ m_szOwnerId = m_szCheckId;
fprintf(fs, "%d Enter your password:\n", CODE_ENTERxPASSWORD);
fflush(fs);
m_nState = STATE_PASSWORD;
@@ -724,14 +733,28 @@
}
case STATE_PASSWORD:
{
- ICQOwner *o = gUserManager.FetchOwner(LOCK_R);
- bool ok = (strcmp(m_szCheckId, o->IdString()) == 0 &&
- (strcmp(o->Password(), data_line) == 0));
+ std::vector<SPluginDataPtr> pluginData;
+ m_daemon.ProtoPluginList(pluginData);
+ std::vector<SPluginDataPtr>::iterator it;
+ bool ok = false;
+ ICQOwner *o = NULL;
+ for (it = pluginData.begin(); it != pluginData.end(); it++)
+ {
+ o = gUserManager.FetchOwner(m_szOwnerId, (*it)->name, LOCK_R);
+ if (o != NULL)
+ ok = (strcmp(m_szCheckId, o->IdString()) == 0 &&
+ (strcmp(o->Password(), data_line) == 0));
+ if (ok)
+ {
+ m_szOwnerProtoName = (*it)->name;
+ break;
+ }
+ }
free(m_szCheckId);
m_szCheckId = 0;
if (!ok)
{
- gUserManager.DropOwner();
+ gUserManager.DropOwner(m_szOwnerId, m_szOwnerProtoName);
gLog.Info("%sClient failed validation from %s.\n", L_RMSxSTR,
sock.RemoteIpStr(buf));
fprintf(fs, "%d Invalid ID/Password.\n", CODE_INVALID);
@@ -743,7 +766,7 @@
fprintf(fs, "%d Hello %s. Type HELP for assistance.\n", CODE_HELLO,
o->GetAlias());
fflush(fs);
- gUserManager.DropOwner();
+ gUserManager.DropOwner(m_szOwnerId, m_szOwnerProtoName);
m_nState = STATE_COMMAND;
break;
}
@@ -884,21 +907,12 @@
// Show status
if (data_arg[0] == '\0')
{
-#if 0
- //FIXME NEWAPI
- ProtoPluginsList l;
- ProtoPluginsListIter it;
- m_daemon.ProtoPluginList(l);
- for (it = l.begin(); it != l.end(); it++)
+ ICQOwner *o = gUserManager.FetchOwner(m_szOwnerId, m_szOwnerProtoName,
LOCK_R);
+ if (o)
{
- ICQOwner *o = gUserManager.FetchOwner((*it)->PPID(), LOCK_R);
- if (o)
- {
- fprintf(fs, "%d %s %s %s\n", CODE_STATUS, o->IdString(),
(*it)->Name(), o->StatusStr());
- gUserManager.DropOwner((*it)->PPID());
- }
+ fprintf(fs, "%d %s %s %s\n", CODE_STATUS, o->IdString(),
m_szOwnerProtoName.c_str(), o->StatusStr());
+ gUserManager.DropOwner(m_szOwnerId, m_szOwnerProtoName);
}
-#endif
fprintf(fs, "%d\n", CODE_STATUSxDONE);
return fflush(fs);
}
@@ -909,16 +923,7 @@
if (nPos == string::npos)
{
unsigned long nStatus = StringToStatus(data_arg);
-#if 0
- //FIXME NEWAPI
- ProtoPluginsList l;
- ProtoPluginsListIter it;
- m_daemon.ProtoPluginList(l);
- for (it = l.begin(); it != l.end(); it++)
- {
- ChangeStatus((*it)->PPID(), nStatus, data_arg);
- }
-#endif
+ ChangeStatus(CProtocolPlugin::Name2Ppid(m_szOwnerProtoName), nStatus,
data_arg);
}
else
{