Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Azoth OTRoid: libotr-4 timer support.

  • Loading branch information...
commit ddf02edc6464cac5ea97034f028fa61dcb1b0ba0 1 parent d9beb14
Georg Rudoy authored
34 src/plugins/azoth/plugins/otroid/otroid.cpp
@@ -30,6 +30,10 @@ extern "C"
30 30 #include <libotr/instag.h>
31 31 }
32 32
  33 +#if OTRL_VERSION_MAJOR >= 4
  34 +#include <QTimer>
  35 +#endif
  36 +
33 37 #include <interfaces/azoth/iprotocol.h>
34 38 #include <interfaces/azoth/iaccount.h>
35 39 #include <interfaces/azoth/iclentry.h>
@@ -88,6 +92,11 @@ namespace OTRoid
88 92 << event
89 93 << msg;
90 94 }
  95 +
  96 + void TimerControl (void *opData, unsigned int interval)
  97 + {
  98 + static_cast<Plugin*> (opData)->SetPollTimerInterval (interval);
  99 + }
91 100 #else
92 101 void LogMsg (void *opData, const char *msg)
93 102 {
@@ -118,7 +127,15 @@ namespace OTRoid
118 127 OtrOps_.account_name_free = &OTR::FreeAccountName;
119 128 #if OTRL_VERSION_MAJOR >= 4
120 129 OtrOps_.handle_msg_event = &OTR::HandleMsgEvent;
121   - //OtrOps_.timer_control = &OTR::TimerControl;
  130 + OtrOps_.timer_control = &OTR::TimerControl;
  131 +
  132 + PollTimer_ = new QTimer (this);
  133 + connect (PollTimer_,
  134 + SIGNAL (timeout ()),
  135 + this,
  136 + SLOT (pollOTR ()));
  137 +
  138 + SetPollTimerInterval (otrl_message_poll_get_default_interval (UserState_));
122 139 #else
123 140 OtrOps_.log_message = &OTR::LogMsg;
124 141 #endif
@@ -225,6 +242,14 @@ namespace OTRoid
225 242 }
226 243
227 244 #if OTRL_VERSION_MAJOR >= 4
  245 + void Plugin::SetPollTimerInterval (unsigned int seconds)
  246 + {
  247 + if (PollTimer_->isActive ())
  248 + PollTimer_->stop ();
  249 +
  250 + if (seconds)
  251 + PollTimer_->start (seconds * 1000);
  252 + }
228 253 #else
229 254 void Plugin::LogMsg (const QString& msg)
230 255 {
@@ -391,6 +416,13 @@ namespace OTRoid
391 416
392 417 Entry2Action_ [entry] = otr;
393 418 }
  419 +
  420 +#if OTRL_VERSION_MAJOR >= 4
  421 + void Plugin::pollOTR ()
  422 + {
  423 + otrl_message_poll (UserState_, &OtrOps_, this);
  424 + }
  425 +#endif
394 426 }
395 427 }
396 428 }
9 src/plugins/azoth/plugins/otroid/otroid.h
@@ -55,6 +55,10 @@ namespace OTRoid
55 55 QHash<QObject*, QAction*> Entry2Action_;
56 56
57 57 QDir OtrDir_;
  58 +
  59 +#if OTRL_VERSION_MAJOR >= 4
  60 + QTimer *PollTimer_;
  61 +#endif
58 62 public:
59 63 void Init (ICoreProxy_ptr);
60 64 void SecondInit ();
@@ -76,6 +80,7 @@ namespace OTRoid
76 80 QString GetAccountName (const QString& accId);
77 81
78 82 #if OTRL_VERSION_MAJOR >= 4
  83 + void SetPollTimerInterval (unsigned int seconds);
79 84 #else
80 85 void LogMsg (const QString&);
81 86 #endif
@@ -97,6 +102,10 @@ namespace OTRoid
97 102 void hookMessageCreated (LeechCraft::IHookProxy_ptr proxy,
98 103 QObject *chatTab,
99 104 QObject *message);
  105 + private slots:
  106 +#if OTRL_VERSION_MAJOR >= 4
  107 + void pollOTR ();
  108 +#endif
100 109 signals:
101 110 void gotEntity (const LeechCraft::Entity&);
102 111 };

0 comments on commit ddf02ed

Please sign in to comment.
Something went wrong with that request. Please try again.