Permalink
Browse files

Azoth OTRoid: basic libotr-4 compatibility.

  • Loading branch information...
1 parent 78801b4 commit d9beb14171f6cf186f16d3fc115d943b47973587 @0xd34df00d committed Oct 20, 2012
Showing with 54 additions and 15 deletions.
  1. +49 −14 src/plugins/azoth/plugins/otroid/otroid.cpp
  2. +5 −1 src/plugins/azoth/plugins/otroid/otroid.h
@@ -25,7 +25,9 @@
extern "C"
{
+#include <libotr/version.h>
#include <libotr/privkey.h>
+#include <libotr/instag.h>
}
#include <interfaces/azoth/iprotocol.h>
@@ -62,11 +64,6 @@ namespace OTRoid
static_cast<Plugin*> (opData)->WriteFingerprints ();
}
- void LogMsg (void *opData, const char *msg)
- {
- static_cast<Plugin*> (opData)->LogMsg (QString::fromUtf8 (msg).trimmed ());
- }
-
const char* GetAccountName (void *opData, const char *acc, const char*)
{
const QString& name = static_cast<Plugin*> (opData)->
@@ -82,6 +79,21 @@ namespace OTRoid
{
delete [] name;
}
+
+#if OTRL_VERSION_MAJOR >= 4
+ void HandleMsgEvent (void*, OtrlMessageEvent event,
+ ConnContext*, const char *msg, gcry_error_t)
+ {
+ qDebug () << Q_FUNC_INFO
+ << event
+ << msg;
+ }
+#else
+ void LogMsg (void *opData, const char *msg)
+ {
+ static_cast<Plugin*> (opData)->LogMsg (QString::fromUtf8 (msg).trimmed ());
+ }
+#endif
}
void Plugin::Init (ICoreProxy_ptr)
@@ -102,9 +114,14 @@ namespace OTRoid
OtrOps_.is_logged_in = &OTR::IsLoggedIn;
OtrOps_.inject_message = &OTR::InjectMessage;
OtrOps_.write_fingerprints = &OTR::WriteFingerprints;
- OtrOps_.log_message = &OTR::LogMsg;
OtrOps_.account_name = &OTR::GetAccountName;
OtrOps_.account_name_free = &OTR::FreeAccountName;
+#if OTRL_VERSION_MAJOR >= 4
+ OtrOps_.handle_msg_event = &OTR::HandleMsgEvent;
+ //OtrOps_.timer_control = &OTR::TimerControl;
+#else
+ OtrOps_.log_message = &OTR::LogMsg;
+#endif
}
void Plugin::SecondInit ()
@@ -191,11 +208,6 @@ namespace OTRoid
otrl_privkey_write_fingerprints (UserState_, GetOTRFilename ("fingerprints"));
}
- void Plugin::LogMsg (const QString& msg)
- {
- qDebug () << "OTR:" << msg;
- }
-
QString Plugin::GetAccountName (const QString& accId)
{
QObject *accObj = AzothProxy_->GetAccount (accId);
@@ -212,6 +224,14 @@ namespace OTRoid
return acc->GetAccountName ();
}
+#if OTRL_VERSION_MAJOR >= 4
+#else
+ void Plugin::LogMsg (const QString& msg)
+ {
+ qDebug () << "OTR:" << msg;
+ }
+#endif
+
void Plugin::initPlugin (QObject *obj)
{
AzothProxy_ = qobject_cast<IProxyObject*> (obj);
@@ -277,7 +297,12 @@ namespace OTRoid
entry->GetEntryID ().toUtf8 ().constData (),
msg->GetBody ().toUtf8 ().constData (),
&newMsg,
- NULL, NULL, NULL);
+ NULL,
+ NULL,
+#if OTRL_VERSION_MAJOR >= 4
+ NULL,
+#endif
+ NULL);
if (ignore)
{
@@ -320,14 +345,24 @@ namespace OTRoid
IProtocol *proto = qobject_cast<IProtocol*> (acc->GetParentProtocol ());
char *newMsg = 0;
- gcry_error_t err = otrl_message_sending (UserState_, &OtrOps_, this,
+ gcry_error_t err = otrl_message_sending (UserState_,
+ &OtrOps_,
+ this,
acc->GetAccountID ().constData (),
proto->GetProtocolID ().constData (),
entry->GetEntryID ().toUtf8 ().constData (),
+#if OTRL_VERSION_MAJOR >= 4
+ OTRL_INSTAG_BEST,
+#endif
msg->GetBody ().toUtf8 ().constData (),
NULL,
&newMsg,
- NULL, NULL);
+#if OTRL_VERSION_MAJOR >= 4
+ OTRL_FRAGMENT_SEND_SKIP,
+ NULL,
+#endif
+ NULL,
+ NULL);
if (err)
{
@@ -73,8 +73,12 @@ namespace OTRoid
Priority, const QString& title,
const QString& primary, const QString& secondary);
void WriteFingerprints ();
- void LogMsg (const QString&);
QString GetAccountName (const QString& accId);
+
+#if OTRL_VERSION_MAJOR >= 4
+#else
+ void LogMsg (const QString&);
+#endif
private:
const char* GetOTRFilename (const QString&) const;
void CreateActions (QObject*);

0 comments on commit d9beb14

Please sign in to comment.