soc.2009.transport: a0846900: More abstract Adhoc class
hanzz at soc.pidgin.im
hanzz at soc.pidgin.im
Sat Jun 13 16:20:22 EDT 2009
-----------------------------------------------------------------
Revision: a0846900f3a20afc48915df8974aa58bcb7117fa
Ancestor: ff1f3f978924715dac0995371901fd3a692dbdb7
Author: hanzz at soc.pidgin.im
Date: 2009-06-13T20:16:58
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/a0846900f3a20afc48915df8974aa58bcb7117fa
Added files:
adhoccommandhandler.h
Modified files:
CMakeLists.txt adhochandler.cpp adhochandler.h
adhocrepeater.h
ChangeLog:
More abstract Adhoc class
-------------- next part --------------
============================================================
--- adhoccommandhandler.h 2ff3ec88623eda46ab09f2a45b31dcc8fed54972
+++ adhoccommandhandler.h 2ff3ec88623eda46ab09f2a45b31dcc8fed54972
@@ -0,0 +1,39 @@
+/**
+ * XMPP - libpurple transport
+ *
+ * Copyright (C) 2009, Jan Kaluza <hanzz at soc.pidgin.im>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#ifndef _HI_ADHOC_COMMAND_HANDLER_H
+#define _HI_ADHOC_COMMAND_HANDLER_H
+
+#include <string>
+#include <list>
+#include "glib.h"
+#include "gloox/iq.h"
+
+using namespace gloox;
+
+class AdhocCommandHandler
+{
+ public:
+ virtual ~AdhocCommandHandler() {}
+
+ virtual bool handleIq(const IQ &iq) = 0;
+};
+
+#endif
============================================================
--- CMakeLists.txt 25c09d1f5f9d96fa52616c8b94ba534ba432f472
+++ CMakeLists.txt cd1f3c9ca955c8a0d398a4ff6cd713be1ec7f55c
@@ -121,6 +121,7 @@
adhochandler.h
localization.h
muchandler.h
+ adhoccommandhandler.h
protocols/abstractprotocol.h
protocols/icq.h
protocols/facebook.h
============================================================
--- adhochandler.cpp bc806f593d320af689a21f791133d0e9e0e207d5
+++ adhochandler.cpp 28e12c5ee42e406d43df01bf7248c33d43dcff02
@@ -191,7 +191,7 @@ bool GlooxAdhocHandler::hasSession(const
}
bool GlooxAdhocHandler::hasSession(const std::string &jid) {
- std::map<std::string,AdhocRepeater *> ::iterator iter = m_sessions.begin();
+ std::map<std::string,AdhocCommandHandler *> ::iterator iter = m_sessions.begin();
iter = m_sessions.find(jid);
if(iter != m_sessions.end())
return true;
============================================================
--- adhochandler.h 7920176d349062588e36f37e3df881e8d08207a2
+++ adhochandler.h 64fb66fbf5b8272e79b374240550475f76ee4158
@@ -26,10 +26,17 @@
#include "user.h"
#include "glib.h"
#include "gloox/disconodehandler.h"
+#include "adhoccommandhandler.h"
class GlooxMessageHandler;
class AdhocRepeater;
+struct adhocCommand {
+ std::string name;
+ std::string node;
+ AdhocCommandHandler (*createHandler)(GlooxMessageHandler *m, User *user);
+};
+
class GlooxAdhocHandler : public DiscoNodeHandler, public DiscoHandler, public IqHandler
{
public:
@@ -43,13 +50,13 @@ class GlooxAdhocHandler : public DiscoNo
void handleDiscoInfo(const JID &jid, const Disco::Info &info, int context);
void handleDiscoItems(const JID &jid, const Disco::Items &items, int context);
void handleDiscoError(const JID &jid, const Error *error, int context);
- void registerSession(const std::string &jid, AdhocRepeater *repeater) {std::cout << jid << "\n"; m_sessions[jid] = repeater; }
+ void registerSession(const std::string &jid, AdhocCommandHandler *handler) {m_sessions[jid] = handler; }
void unregisterSession(std::string &jid) { m_sessions.erase(jid); }
bool hasSession(const std::string &jid);
private:
GlooxMessageHandler *main;
- std::map<std::string, AdhocRepeater *> m_sessions;
+ std::map<std::string, AdhocCommandHandler *> m_sessions;
};
============================================================
--- adhocrepeater.h 75ace4d4215e0a0f5fecebfa5df8db233e0df515
+++ adhocrepeater.h 579e6f42bcb123ea182300bdf7a7acbf26fab1f8
@@ -26,11 +26,12 @@
#include "user.h"
#include "glib.h"
#include "request.h"
+#include "adhoccommandhandler.h"
class GlooxMessageHandler;
class User;
-class AdhocRepeater
+class AdhocRepeater : public AdhocCommandHandler
{
public:
AdhocRepeater(GlooxMessageHandler *m, User *user, const std::string &title, const std::string &primaryString, const std::string &secondaryString, const std::string &value, gboolean multiline, gboolean masked, GCallback ok_cb, GCallback cancel_cb, void * user_data);
More information about the Commits
mailing list