[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [Konversation] d6eee5a: Work on DCOP interface
From:       Dario Abatianni <eisfuchs () tigress ! com>
Date:       2010-07-01 13:26:56
Message-ID: 20100701132656.28DCCBB548D () projects ! kde ! org
[Download RAW message or body]

commit d6eee5a4a12ce40740b38635355176ce02d48797
Author: Dario Abatianni <eisfuchs@tigress.com>
Date:   Mon Oct 13 21:01:12 2003 +0000

    Work on DCOP interface
    
    svn path=/trunk/kdeextragear-2/konversation/; revision=258665

diff --git a/konversation/event.h b/konversation/event.h
index b110d40..08c214b 100644
--- a/konversation/event.h
+++ b/konversation/event.h
@@ -1,32 +1,35 @@
 #ifndef EVENT_H
 #define EVENT_H
 
-enum EVENT_TYPE {
-    ON_JOIN,
-    ON_QUIT,
-    ON_INVITE,
-    ON_PART,
-    ON_CTCP,
-    ON_CTCP_REPLY,
-    ON_MESSAGE,
-    ON_NOTICE,
-    ON_KICK,
-    ON_TOPIC,
-    ON_NICK_CHANGE,
-    ON_MODE,
-    ON_NUMERIC,
-    ON_ANY
+enum EVENT_TYPE
+{
+  ON_JOIN,
+  ON_QUIT,
+  ON_INVITE,
+  ON_PART,
+  ON_CTCP,
+  ON_CTCP_REPLY,
+  ON_MESSAGE,
+  ON_NOTICE,
+  ON_KICK,
+  ON_TOPIC,
+  ON_NICK_CHANGE,
+  ON_MODE,
+  ON_NUMERIC,
+  ON_ANY
 };
 
 class IRCEvent
 {
- public:
+  public:
+    IRCEvent (const QString &type, const QString &criteria, const QString &app, \
const QString &object, const QString &signal, int id); +    EVENT_TYPE type;
+    QString appId, objectId, criteria, signal;
+    // Criteria: "sourceregexp:targetregexp:dataregexp"
+    int hookId();
 
-  IRCEvent (const QString &type, const QString &criteria, const QString &app, const \
                QString &object, const QString &signal);
-  EVENT_TYPE type;
-  QString appId, objectId, criteria, signal;
-  // Criteria: "sourceregexp:targetregexp:dataregexp"
+  protected:
+    int id;
 };
 
-
 #endif
diff --git a/konversation/konvdcop.cpp b/konversation/konvdcop.cpp
index 3fc7c0b..ef54b8b 100644
--- a/konversation/konvdcop.cpp
+++ b/konversation/konvdcop.cpp
@@ -16,6 +16,9 @@ KonvDCOP::KonvDCOP()
       : DCOPObject("Konversation"),
         QObject(0,"Konversation")
 {
+  // reset hook counter
+  hookId=0;
+
   if(!kapp->dcopClient()->isRegistered())
   {
     kapp->dcopClient()->registerAs("konversation");
@@ -62,17 +65,43 @@ void KonvDCOP::error(const QString& string)
  type when matching code is done.
 */
 
-void KonvDCOP::registerEventHook (const QString &type, const QString &criteria, \
const QString &app, const QString &object, const QString &signal) +int \
KonvDCOP::registerEventHook(const QString& type, +                                \
const QString& criteria, +                                const QString& app,
+                                const QString& object,
+                                const QString& signal)
 {
-  // append
-  registered_events.append(new IRCEvent(type, criteria, app, object, signal));
+  hookId++; // FIXME: remember that this could wrap around sometimes! Find a better \
way! +
+  // add new event to registered list of event hooks. the id is needed to help \
unregistering +  registered_events.append(new \
IRCEvent(type,criteria,app,object,signal,hookId)); +
+  return hookId;
 }
 
-void KonvDCOP::unregisterEventHook (int /*id*/)
+void KonvDCOP::unregisterEventHook(int hookId)
 {
+  // go through the list of registered events
+  for(unsigned int index=0;index<registered_events.count();index++)
+  {
+    // if we found the id we were looking for ...
+    if(registered_events.at(index)->hookId()==hookId)
+    {
+      // ... remove it and return
+      registered_events.remove(index);
+      kdDebug() << "KonvDCOP::unregisterEventHook(): hook id " << hookId << " \
removed. Remaining hooks: " << registered_events.count() << endl; +      return;
+    }
+  } // endfor
+  kdDebug() << "KonvDCOP::unregisterEventHook(): hook id " << hookId << " not \
found!" << endl;  }
 
-IRCEvent::IRCEvent (const QString &a_type, const QString &a_criteria, const QString \
&a_app, const QString &a_obj, const QString &a_signal) +IRCEvent::IRCEvent (const \
QString &a_type, +                    const QString &a_criteria,
+                    const QString &a_app,
+                    const QString &a_obj,
+                    const QString &a_signal,
+                    int a_id)
 {
   QString l_type = a_type.lower();
 
@@ -110,15 +139,22 @@ IRCEvent::IRCEvent (const QString &a_type, const QString \
&a_criteria, const QStr  objectId = a_obj;
   criteria = a_criteria;
   signal = a_signal;
+  id = a_id;
 /*
   kdDebug() << "IRCEvent(): type=" << type  << endl
             << "            criteria=" << criteria << endl
             << "            app=" << a_app << endl
             << "            object=" << a_obj << endl
-            << "            signal=" << a_signal << endl;
+            << "            signal=" << a_signal << endl
+            << "            id=" << id << endl;
 */
 }
 
+int IRCEvent::hookId()
+{
+  return id;
+}
+
 bool KonvDCOP::isIgnore (int serverid, const QString &hostmask, Ignore::Type type)
 {
   return isIgnore(serverid, hostmask, static_cast<int>(type));
diff --git a/konversation/konvdcop.h b/konversation/konvdcop.h
index 3770731..b12726e 100644
--- a/konversation/konvdcop.h
+++ b/konversation/konvdcop.h
@@ -13,19 +13,19 @@ class KonvDCOP : public QObject, virtual public KonvIface
   Q_OBJECT
 
   public:
-  KonvDCOP ();
+    KonvDCOP();
     QPtrList<IRCEvent> registered_events;
 
-  bool isIgnore (int serverid, const QString &hostmask, Ignore::Type type);
-  bool isIgnore (int serverid, const QString &hostmask, int type);
-  QString getNickname (int serverid);
+    bool isIgnore (int serverid, const QString &hostmask, Ignore::Type type);
+    bool isIgnore (int serverid, const QString &hostmask, int type);
+    QString getNickname (int serverid);
 
   signals:
     void dcopSay(const QString& server,const QString& target,const QString& \
command);  void dcopInfo(const QString& string);
 
   public slots:
-    void registerEventHook (const QString &type, const QString &criteria, const \
QString &app, const QString &object, const QString &signal); +    int \
registerEventHook(const QString& type,const QString& criteria,const QString& \
app,const QString& object,const QString& signal);  void unregisterEventHook (int id);
 
     void raw(const QString& server,const QString& command);
@@ -33,6 +33,9 @@ class KonvDCOP : public QObject, virtual public KonvIface
     void info(const QString& string);
     void debug(const QString& string);
     void error(const QString& string);
+
+  protected:
+    int hookId;
 };
 
 class KonvIdentDCOP : public QObject, virtual public KonvIdentityIface
@@ -40,7 +43,7 @@ class KonvIdentDCOP : public QObject, virtual public \
KonvIdentityIface  Q_OBJECT
 
   public:
-  KonvIdentDCOP ();
+  KonvIdentDCOP();
 
   void setrealName(const QString &identity, const QString& name);
   QString getrealName(const QString &identity);
@@ -70,7 +73,7 @@ class KonvIdentDCOP : public QObject, virtual public \
KonvIdentityIface  QString getAwayMessage(const QString &identity);
   void setReturnMessage(const QString &identity, const QString& message);
   QString getReturnMessage(const QString &identity);
-  
+
 };
 
 class KonvPrefsDCOP : public QObject, virtual public KonvPreferencesIface
@@ -114,7 +117,7 @@ class KonvPrefsDCOP : public QObject, virtual public \
KonvPreferencesIface  void setBringToFront(bool state);
   bool getBringToFront();
   void setCloseButtonsOnTabs(bool state);
-  bool getCloseButtonsOnTabs();  
+  bool getCloseButtonsOnTabs();
   int getNotifyDelay();
   void setNotifyDelay(int delay);
   bool getUseNotify();
diff --git a/konversation/konviface.h b/konversation/konviface.h
index f92e5e1..42d7f1f 100644
--- a/konversation/konviface.h
+++ b/konversation/konviface.h
@@ -18,7 +18,7 @@ class KonvIface : virtual public DCOPObject
     virtual void info(const QString& string) = 0;
     virtual void debug(const QString& string) = 0;
     virtual void error(const QString& string) = 0;
-    virtual void registerEventHook (const QString &type, const QString &criteria, \
const QString &app, const QString &object, const QString &signal) = 0; +    virtual \
int registerEventHook (const QString &type, const QString &criteria, const QString \
&app, const QString &object, const QString &signal) = 0;  virtual void \
                unregisterEventHook (int id) = 0;
     virtual bool isIgnore (int serverid, const QString &hostmask, int type) = 0;
     virtual QString getNickname (int serverid) = 0;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic