* Renamed Jabber to JabberHandler as a base class for XMPP protocols.
* Added gtalk and facebook.
This commit is contained in:
parent
0706699184
commit
435efc7c9f
|
@ -0,0 +1,19 @@
|
|||
Caya GPL Protocols contributors list
|
||||
====================================
|
||||
|
||||
If you are not in this list, just send us an email.
|
||||
We will add you!
|
||||
|
||||
== Core developers ==
|
||||
|
||||
* Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
|
||||
|
||||
== Icons ==
|
||||
|
||||
Michele Frau <zumikkebe@gmail.com>
|
||||
|
||||
* GoogleTalk protocol
|
||||
|
||||
Mark Erben <markerben@googlemail.com>
|
||||
|
||||
* Facebook protocol
|
Binary file not shown.
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the GPL v2 License.
|
||||
*
|
||||
* Authors:
|
||||
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
||||
*/
|
||||
|
||||
#include "FacebookProtocol.h"
|
||||
|
||||
extern "C" __declspec(dllexport) CayaProtocol* protocol();
|
||||
extern "C" __declspec(dllexport) const char* signature();
|
||||
extern "C" __declspec(dllexport) const char* friendly_signature();
|
||||
|
||||
CayaProtocol*
|
||||
protocol()
|
||||
{
|
||||
return (CayaProtocol*)new FacebookProtocol();
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
signature()
|
||||
{
|
||||
return kProtocolSignature;
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
friendly_signature()
|
||||
{
|
||||
return kProtocolName;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the GPL v2 License.
|
||||
*
|
||||
* Authors:
|
||||
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
||||
*/
|
||||
|
||||
#include "FacebookProtocol.h"
|
||||
|
||||
const char* kProtocolSignature = "facebook";
|
||||
const char* kProtocolName = "Facebook";
|
||||
|
||||
|
||||
FacebookProtocol::FacebookProtocol()
|
||||
: JabberHandler()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FacebookProtocol::~FacebookProtocol()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FacebookProtocol::OverrideSettings()
|
||||
{
|
||||
fServer = "chat.facebook.com";
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
FacebookProtocol::ComposeJID() const
|
||||
{
|
||||
BString jid(fUsername);
|
||||
jid << "@" << fServer << "/" << fResource;
|
||||
return jid;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the GPL v2 License.
|
||||
*/
|
||||
#ifndef _FACEBOOK_PROTOCOL_H
|
||||
#define _FACEBOOK_PROTOCOL_H
|
||||
|
||||
#include "JabberHandler.h"
|
||||
|
||||
class FacebookProtocol : public JabberHandler {
|
||||
public:
|
||||
FacebookProtocol();
|
||||
virtual ~FacebookProtocol();
|
||||
|
||||
virtual void OverrideSettings();
|
||||
virtual BString ComposeJID() const;
|
||||
};
|
||||
|
||||
#endif // _FACEBOOK_PROTOCOL_H
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the GPL v2 License.
|
||||
*
|
||||
* Authors:
|
||||
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
||||
*/
|
||||
|
||||
#include "GoogleTalkProtocol.h"
|
||||
|
||||
extern "C" __declspec(dllexport) CayaProtocol* protocol();
|
||||
extern "C" __declspec(dllexport) const char* signature();
|
||||
extern "C" __declspec(dllexport) const char* friendly_signature();
|
||||
|
||||
CayaProtocol*
|
||||
protocol()
|
||||
{
|
||||
return (CayaProtocol*)new GoogleTalkProtocol();
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
signature()
|
||||
{
|
||||
return kProtocolSignature;
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
friendly_signature()
|
||||
{
|
||||
return kProtocolName;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the GPL v2 License.
|
||||
*
|
||||
* Authors:
|
||||
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
||||
*/
|
||||
|
||||
#include "GoogleTalkProtocol.h"
|
||||
|
||||
const char* kProtocolSignature = "gtalk";
|
||||
const char* kProtocolName = "GoogleTalk";
|
||||
|
||||
|
||||
GoogleTalkProtocol::GoogleTalkProtocol()
|
||||
: JabberHandler()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
GoogleTalkProtocol::~GoogleTalkProtocol()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GoogleTalkProtocol::OverrideSettings()
|
||||
{
|
||||
fServer = "talk.google.com";
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
GoogleTalkProtocol::ComposeJID() const
|
||||
{
|
||||
BString jid(fUsername);
|
||||
if (jid.FindLast("@") < 0)
|
||||
jid << "@gmail.com";
|
||||
jid << "/" << fResource;
|
||||
return jid;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the GPL v2 License.
|
||||
*/
|
||||
#ifndef _GOOGLE_TALK_PROTOCOL_H
|
||||
#define _GOOGLE_TALK_PROTOCOL_H
|
||||
|
||||
#include "JabberHandler.h"
|
||||
|
||||
class GoogleTalkProtocol : public JabberHandler {
|
||||
public:
|
||||
GoogleTalkProtocol();
|
||||
virtual ~GoogleTalkProtocol();
|
||||
|
||||
virtual void OverrideSettings();
|
||||
virtual BString ComposeJID() const;
|
||||
};
|
||||
|
||||
#endif // _GOOGLE_TALK_PROTOCOL_H
|
|
@ -8,11 +8,9 @@
|
|||
|
||||
//#include <libsupport/Base64.h>
|
||||
|
||||
#include "CayaProtocolMessages.h"
|
||||
#include "Jabber.h"
|
||||
#include <CayaProtocolMessages.h>
|
||||
|
||||
const char* kProtocolSignature = "jabber";
|
||||
const char* kProtocolName = "Jabber";
|
||||
#include "JabberHandler.h"
|
||||
|
||||
|
||||
static status_t
|
||||
|
@ -22,24 +20,21 @@ connect_thread(void* data)
|
|||
if (!client)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
#if 1
|
||||
client->connect();
|
||||
#else
|
||||
client->recv(-1);
|
||||
#endif
|
||||
while (client->recv(1000) == gloox::ConnNoError);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
Jabber::Jabber()
|
||||
: fClient(NULL),
|
||||
JabberHandler::JabberHandler()
|
||||
:
|
||||
fClient(NULL),
|
||||
fVCardManager(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Jabber::~Jabber()
|
||||
JabberHandler::~JabberHandler()
|
||||
{
|
||||
fVCardManager->cancelVCardOperations(this);
|
||||
Shutdown();
|
||||
|
@ -47,7 +42,7 @@ Jabber::~Jabber()
|
|||
|
||||
|
||||
status_t
|
||||
Jabber::Init(CayaProtocolMessengerInterface* messenger)
|
||||
JabberHandler::Init(CayaProtocolMessengerInterface* messenger)
|
||||
{
|
||||
fServerMessenger = messenger;
|
||||
|
||||
|
@ -56,7 +51,7 @@ Jabber::Init(CayaProtocolMessengerInterface* messenger)
|
|||
|
||||
|
||||
status_t
|
||||
Jabber::Process(BMessage* msg)
|
||||
JabberHandler::Process(BMessage* msg)
|
||||
{
|
||||
if (msg->what != IM_MESSAGE)
|
||||
return B_ERROR;
|
||||
|
@ -73,8 +68,10 @@ Jabber::Process(BMessage* msg)
|
|||
switch (status) {
|
||||
case CAYA_ONLINE:
|
||||
// Log in if we still need to
|
||||
if (!fClient->authed())
|
||||
fClient->login();
|
||||
resume_thread(fRecvThread);
|
||||
break;
|
||||
case CAYA_OFFLINE:
|
||||
kill_thread(fRecvThread);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -89,13 +86,13 @@ Jabber::Process(BMessage* msg)
|
|||
if (!id || !body)
|
||||
return B_ERROR;
|
||||
|
||||
// Send Jabber message
|
||||
// Send JabberHandler message
|
||||
gloox::Message jm(gloox::Message::Chat, gloox::JID(id),
|
||||
body, (subject ? subject : gloox::EmptyString));
|
||||
fClient->send(jm);
|
||||
|
||||
// Tell Caya we actually sent the message
|
||||
MessageSent(id, subject, body);
|
||||
_MessageSent(id, subject, body);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -107,7 +104,7 @@ Jabber::Process(BMessage* msg)
|
|||
|
||||
|
||||
status_t
|
||||
Jabber::Shutdown()
|
||||
JabberHandler::Shutdown()
|
||||
{
|
||||
if (fClient)
|
||||
fClient->disconnect();
|
||||
|
@ -116,21 +113,21 @@ Jabber::Shutdown()
|
|||
|
||||
|
||||
const char*
|
||||
Jabber::Signature() const
|
||||
JabberHandler::Signature() const
|
||||
{
|
||||
return kProtocolSignature;
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
Jabber::FriendlySignature() const
|
||||
JabberHandler::FriendlySignature() const
|
||||
{
|
||||
return kProtocolName;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Jabber::UpdateSettings(BMessage* msg)
|
||||
JabberHandler::UpdateSettings(BMessage* msg)
|
||||
{
|
||||
const char* username = msg->FindString("username");
|
||||
const char* password = msg->FindString("password");
|
||||
|
@ -138,7 +135,7 @@ Jabber::UpdateSettings(BMessage* msg)
|
|||
const char* resource = msg->FindString("resource");
|
||||
|
||||
// Sanity check
|
||||
if (!username || !password || !server || !resource)
|
||||
if (!username || !password || !resource)
|
||||
return B_ERROR;
|
||||
|
||||
// Store settings
|
||||
|
@ -147,18 +144,15 @@ Jabber::UpdateSettings(BMessage* msg)
|
|||
fServer = server;
|
||||
fResource = resource;
|
||||
|
||||
// Compose jid
|
||||
BString jidString(fUsername);
|
||||
jidString << "@" << fServer << "/" << fResource;
|
||||
gloox::JID jid(jidString.String());
|
||||
// Give the add-on a change to override settings
|
||||
OverrideSettings();
|
||||
|
||||
// Compose JID
|
||||
BString jid = ComposeJID();
|
||||
|
||||
// Register our client
|
||||
fClient = new gloox::Client(jid, fPassword.String());
|
||||
#if 0
|
||||
fConnection = new gloox::ConnectionTCPClient(fClient, fClient->logInstance(),
|
||||
fServer.String(), 5222);
|
||||
fClient->setConnectionImpl(fConnection);
|
||||
#endif
|
||||
fClient = new gloox::Client(gloox::JID(jid.String()), fPassword.String());
|
||||
fClient->setServer(fServer.String());
|
||||
fClient->registerConnectionListener(this);
|
||||
fClient->registerMessageHandler(this);
|
||||
fClient->rosterManager()->registerRosterListener(this);
|
||||
|
@ -170,35 +164,34 @@ Jabber::UpdateSettings(BMessage* msg)
|
|||
// Register vCard manager
|
||||
fVCardManager = new gloox::VCardManager(fClient);
|
||||
|
||||
#if 0
|
||||
// Connect to the server
|
||||
fClient->connect(false);
|
||||
#endif
|
||||
|
||||
// Read data from another thread
|
||||
// FIXME: Maybe get data using select() and recv() on the socket
|
||||
thread_id tid = spawn_thread(connect_thread, "connect_thread",
|
||||
fRecvThread = spawn_thread(connect_thread, "connect_thread",
|
||||
B_NORMAL_PRIORITY, (void*)fClient);
|
||||
return resume_thread(tid);
|
||||
if (fRecvThread < B_OK)
|
||||
return B_ERROR;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
uint32
|
||||
Jabber::GetEncoding()
|
||||
JabberHandler::GetEncoding()
|
||||
{
|
||||
return 0xffff;
|
||||
}
|
||||
|
||||
|
||||
CayaProtocolMessengerInterface*
|
||||
Jabber::MessengerInterface() const
|
||||
JabberHandler::MessengerInterface() const
|
||||
{
|
||||
return fServerMessenger;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::MessageSent(const char* id, const char* subject,
|
||||
JabberHandler::_MessageSent(const char* id, const char* subject,
|
||||
const char* body)
|
||||
{
|
||||
BMessage msg(IM_MESSAGE);
|
||||
|
@ -212,7 +205,7 @@ Jabber::MessageSent(const char* id, const char* subject,
|
|||
|
||||
|
||||
CayaStatus
|
||||
Jabber::GlooxStatusToCaya(gloox::Presence::PresenceType type)
|
||||
JabberHandler::_GlooxStatusToCaya(gloox::Presence::PresenceType type)
|
||||
{
|
||||
switch (type) {
|
||||
case gloox::Presence::Available:
|
||||
|
@ -240,7 +233,7 @@ Jabber::GlooxStatusToCaya(gloox::Presence::PresenceType type)
|
|||
|
||||
|
||||
void
|
||||
Jabber::onConnect()
|
||||
JabberHandler::onConnect()
|
||||
{
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_OWN_STATUS_SET);
|
||||
|
@ -251,7 +244,7 @@ Jabber::onConnect()
|
|||
|
||||
|
||||
void
|
||||
Jabber::onDisconnect(gloox::ConnectionError e)
|
||||
JabberHandler::onDisconnect(gloox::ConnectionError e)
|
||||
{
|
||||
BMessage msg(IM_MESSAGE);
|
||||
msg.AddInt32("im_what", IM_OWN_STATUS_SET);
|
||||
|
@ -262,20 +255,20 @@ Jabber::onDisconnect(gloox::ConnectionError e)
|
|||
|
||||
|
||||
bool
|
||||
Jabber::onTLSConnect(const gloox::CertInfo& info)
|
||||
JabberHandler::onTLSConnect(const gloox::CertInfo& info)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::onResourceBindError(const gloox::Error* error)
|
||||
JabberHandler::onResourceBindError(const gloox::Error* error)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::handleRoster(const gloox::Roster& roster)
|
||||
JabberHandler::handleRoster(const gloox::Roster& roster)
|
||||
{
|
||||
std::list<BMessage> msgs;
|
||||
|
||||
|
@ -332,7 +325,7 @@ Jabber::handleRoster(const gloox::Roster& roster)
|
|||
|
||||
|
||||
void
|
||||
Jabber::handleMessage(const gloox::Message& m, gloox::MessageSession*)
|
||||
JabberHandler::handleMessage(const gloox::Message& m, gloox::MessageSession*)
|
||||
{
|
||||
// Only chat messages are handled now
|
||||
if (m.subtype() != gloox::Message::Chat)
|
||||
|
@ -353,37 +346,37 @@ Jabber::handleMessage(const gloox::Message& m, gloox::MessageSession*)
|
|||
|
||||
|
||||
void
|
||||
Jabber::handleItemAdded(const gloox::JID&)
|
||||
JabberHandler::handleItemAdded(const gloox::JID&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::handleItemSubscribed(const gloox::JID&)
|
||||
JabberHandler::handleItemSubscribed(const gloox::JID&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::handleItemUnsubscribed(const gloox::JID&)
|
||||
JabberHandler::handleItemUnsubscribed(const gloox::JID&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::handleItemRemoved(const gloox::JID&)
|
||||
JabberHandler::handleItemRemoved(const gloox::JID&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::handleItemUpdated(const gloox::JID&)
|
||||
JabberHandler::handleItemUpdated(const gloox::JID&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::handleRosterPresence(const gloox::RosterItem& item,
|
||||
JabberHandler::handleRosterPresence(const gloox::RosterItem& item,
|
||||
const std::string&,
|
||||
gloox::Presence::PresenceType type,
|
||||
const std::string& presenceMsg)
|
||||
|
@ -392,14 +385,14 @@ Jabber::handleRosterPresence(const gloox::RosterItem& item,
|
|||
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||
msg.AddString("protocol", kProtocolSignature);
|
||||
msg.AddString("id", item.jid().c_str());
|
||||
msg.AddInt32("status", GlooxStatusToCaya(type));
|
||||
msg.AddInt32("status", _GlooxStatusToCaya(type));
|
||||
msg.AddString("message", presenceMsg.c_str());
|
||||
fServerMessenger->SendMessage(&msg);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::handleSelfPresence(const gloox::RosterItem& item, const std::string&,
|
||||
JabberHandler::handleSelfPresence(const gloox::RosterItem& item, const std::string&,
|
||||
gloox::Presence::PresenceType type,
|
||||
const std::string& presenceMsg)
|
||||
{
|
||||
|
@ -411,40 +404,40 @@ Jabber::handleSelfPresence(const gloox::RosterItem& item, const std::string&,
|
|||
msg.AddInt32("subscription", item.subscription());
|
||||
//resource
|
||||
//groups
|
||||
msg.AddInt32("status", GlooxStatusToCaya(type));
|
||||
msg.AddInt32("status", _GlooxStatusToCaya(type));
|
||||
msg.AddString("message", presenceMsg.c_str());
|
||||
fServerMessenger->SendMessage(&msg);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Jabber::handleSubscriptionRequest(const gloox::JID&, const std::string&)
|
||||
JabberHandler::handleSubscriptionRequest(const gloox::JID&, const std::string&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Jabber::handleUnsubscriptionRequest(const gloox::JID&, const std::string&)
|
||||
JabberHandler::handleUnsubscriptionRequest(const gloox::JID&, const std::string&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::handleNonrosterPresence(const gloox::Presence&)
|
||||
JabberHandler::handleNonrosterPresence(const gloox::Presence&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::handleRosterError(const gloox::IQ&)
|
||||
JabberHandler::handleRosterError(const gloox::IQ&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Jabber::handleLog(gloox::LogLevel level, gloox::LogArea,
|
||||
JabberHandler::handleLog(gloox::LogLevel level, gloox::LogArea,
|
||||
const std::string& msg)
|
||||
{
|
||||
if (level >= gloox::LogLevelWarning)
|
||||
|
@ -453,7 +446,7 @@ Jabber::handleLog(gloox::LogLevel level, gloox::LogArea,
|
|||
|
||||
|
||||
void
|
||||
Jabber::handleVCard(const gloox::JID& jid, const gloox::VCard* card)
|
||||
JabberHandler::handleVCard(const gloox::JID& jid, const gloox::VCard* card)
|
||||
{
|
||||
if (!card)
|
||||
return;
|
||||
|
@ -484,7 +477,7 @@ Jabber::handleVCard(const gloox::JID& jid, const gloox::VCard* card)
|
|||
|
||||
|
||||
void
|
||||
Jabber::handleVCardResult(gloox::VCardHandler::VCardContext context,
|
||||
JabberHandler::handleVCardResult(gloox::VCardHandler::VCardContext context,
|
||||
const gloox::JID& jid,
|
||||
gloox::StanzaError)
|
||||
{
|
|
@ -2,8 +2,8 @@
|
|||
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the GPL v2 License.
|
||||
*/
|
||||
#ifndef _JABBER_H
|
||||
#define _JABBER_H
|
||||
#ifndef _JABBER_HANDLER_H
|
||||
#define _JABBER_HANDLER_H
|
||||
|
||||
#include <String.h>
|
||||
|
||||
|
@ -24,11 +24,11 @@
|
|||
#include "CayaProtocol.h"
|
||||
#include "CayaConstants.h"
|
||||
|
||||
class Jabber : public CayaProtocol, gloox::RosterListener, gloox::ConnectionListener,
|
||||
class JabberHandler : public CayaProtocol, gloox::RosterListener, gloox::ConnectionListener,
|
||||
gloox::LogHandler, gloox::MessageHandler, gloox::VCardHandler {
|
||||
public:
|
||||
Jabber();
|
||||
virtual ~Jabber();
|
||||
JabberHandler();
|
||||
virtual ~JabberHandler();
|
||||
|
||||
virtual status_t Init(CayaProtocolMessengerInterface*);
|
||||
|
||||
|
@ -46,12 +46,16 @@ public:
|
|||
virtual CayaProtocolMessengerInterface*
|
||||
MessengerInterface() const;
|
||||
|
||||
private:
|
||||
virtual void OverrideSettings() = 0;
|
||||
virtual BString ComposeJID() const = 0;
|
||||
|
||||
protected:
|
||||
BString fUsername;
|
||||
BString fPassword;
|
||||
BString fServer;
|
||||
BString fResource;
|
||||
|
||||
private:
|
||||
CayaProtocolMessengerInterface*
|
||||
fServerMessenger;
|
||||
|
||||
|
@ -60,9 +64,11 @@ private:
|
|||
fConnection;
|
||||
gloox::VCardManager* fVCardManager;
|
||||
|
||||
void MessageSent(const char* id, const char* subject,
|
||||
thread_id fRecvThread;
|
||||
|
||||
void _MessageSent(const char* id, const char* subject,
|
||||
const char* body);
|
||||
CayaStatus GlooxStatusToCaya(gloox::Presence::PresenceType type);
|
||||
CayaStatus _GlooxStatusToCaya(gloox::Presence::PresenceType type);
|
||||
|
||||
virtual void onConnect();
|
||||
virtual void onDisconnect(gloox::ConnectionError);
|
||||
|
@ -94,4 +100,4 @@ private:
|
|||
extern const char* kProtocolSignature;
|
||||
extern const char* kProtocolName;
|
||||
|
||||
#endif // _JABBER_H
|
||||
#endif // _JABBER_HANDLER_H
|
|
@ -1,4 +1,12 @@
|
|||
#include "Jabber.h"
|
||||
/*
|
||||
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the GPL v2 License.
|
||||
*
|
||||
* Authors:
|
||||
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
||||
*/
|
||||
|
||||
#include "JabberProtocol.h"
|
||||
|
||||
extern "C" __declspec(dllexport) CayaProtocol* protocol();
|
||||
extern "C" __declspec(dllexport) const char* signature();
|
||||
|
@ -7,7 +15,7 @@ extern "C" __declspec(dllexport) const char* friendly_signature();
|
|||
CayaProtocol*
|
||||
protocol()
|
||||
{
|
||||
return (CayaProtocol*)new Jabber();
|
||||
return (CayaProtocol*)new JabberProtocol();
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the GPL v2 License.
|
||||
*
|
||||
* Authors:
|
||||
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
||||
*/
|
||||
|
||||
#include "JabberProtocol.h"
|
||||
|
||||
const char* kProtocolSignature = "jabber";
|
||||
const char* kProtocolName = "Jabber";
|
||||
|
||||
|
||||
JabberProtocol::JabberProtocol()
|
||||
: JabberHandler()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
JabberProtocol::~JabberProtocol()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
JabberProtocol::OverrideSettings()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
JabberProtocol::ComposeJID() const
|
||||
{
|
||||
BString jid(fUsername);
|
||||
if (jid.FindLast("@") < 0)
|
||||
jid << "@" << fServer;
|
||||
jid << "/" << fResource;
|
||||
return jid;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
|
||||
* Distributed under the terms of the GPL v2 License.
|
||||
*/
|
||||
#ifndef _JABBER_PROTOCOL_H
|
||||
#define _JABBER_PROTOCOL_H
|
||||
|
||||
#include "JabberHandler.h"
|
||||
|
||||
class JabberProtocol : public JabberHandler {
|
||||
public:
|
||||
JabberProtocol();
|
||||
virtual ~JabberProtocol();
|
||||
|
||||
virtual void OverrideSettings();
|
||||
virtual BString ComposeJID() const;
|
||||
};
|
||||
|
||||
#endif // _JABBER_PROTOCOL_H
|
|
@ -1,20 +1,42 @@
|
|||
SubDir TOP protocols jabber ;
|
||||
|
||||
SubDirSysHdrs [ FDirName $(TOP) ] ;
|
||||
SubDirSysHdrs [ FDirName $(TOP) application ] ;
|
||||
SubDirSysHdrs [ FDirName $(TOP) libs ] ;
|
||||
SubDirSysHdrs [ FDirName $(OPENSSL_INCLUDE_DIR) ] ;
|
||||
SubDirSysHdrs [ FDirName $(CAYA_INCLUDE_DIR) ] ;
|
||||
|
||||
AddOn jabber :
|
||||
main.cpp
|
||||
Jabber.cpp
|
||||
JabberMain.cpp
|
||||
JabberProtocol.cpp
|
||||
JabberHandler.cpp
|
||||
: be libgloox.a network ssl crypto z $(TARGET_LIBSTDC++)
|
||||
: jabber.rdef settings_template.rdef
|
||||
: jabber.rdef jabber_settings.rdef
|
||||
;
|
||||
|
||||
AddOn gtalk :
|
||||
GoogleTalkMain.cpp
|
||||
GoogleTalkProtocol.cpp
|
||||
JabberHandler.cpp
|
||||
: be libgloox.a network ssl crypto z $(TARGET_LIBSTDC++)
|
||||
: gtalk.rdef gtalk_settings.rdef
|
||||
;
|
||||
|
||||
AddOn facebook :
|
||||
FacebookMain.cpp
|
||||
FacebookProtocol.cpp
|
||||
JabberHandler.cpp
|
||||
: be libgloox.a network ssl crypto z $(TARGET_LIBSTDC++)
|
||||
: facebook.rdef facebook_settings.rdef
|
||||
;
|
||||
|
||||
Depends jabber : libgloox.a ;
|
||||
Depends gtalk : libgloox.a ;
|
||||
Depends facebook : libgloox.a ;
|
||||
|
||||
LINKFLAGS on jabber += -L$(OPENSSL_LIBRARY_DIR) ;
|
||||
LINKFLAGS on gtalk += -L$(OPENSSL_LIBRARY_DIR) ;
|
||||
LINKFLAGS on facebook += -L$(OPENSSL_LIBRARY_DIR) ;
|
||||
|
||||
InstallBin $(CAYA_DIRECTORY)/protocols : jabber ;
|
||||
InstallBin $(CAYA_DIRECTORY)/protocols : gtalk ;
|
||||
InstallBin $(CAYA_DIRECTORY)/protocols : facebook ;
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
resource app_version {
|
||||
major = 0,
|
||||
middle = 0,
|
||||
minor = 1,
|
||||
|
||||
variety = B_APPV_ALPHA,
|
||||
internal = 0,
|
||||
|
||||
short_info = "Facebook Protocol AddOn for Caya",
|
||||
long_info = "©2010 Pier Luigi Fiorini"
|
||||
};
|
||||
|
||||
resource vector_icon {
|
||||
$"6E6369660202000602000000C000004000000000009220244C000067003C7FFF"
|
||||
$"1A5EA805FF0206111B1111BD01C0A72B4828BF72B8033FBBBA3C39463F5C4A46"
|
||||
$"523C4ABC4D4ABB7A4ABC4DC3D234C59634C51C34C659BB0E54352C0208242824"
|
||||
$"2624BA4724C94924C528245AB6245C265CBA355CC94B5CC5285C5A5C5CC9565C"
|
||||
$"5A5CC5485CB64A5CBA7B5C26C951245A24C55D242824BA53242624020A000101"
|
||||
$"000A01010000"
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
resource(1000) message('IMst') {
|
||||
"setting" = message {
|
||||
"name" = "username",
|
||||
"description" = "Username",
|
||||
int32 "type" = 'CSTR'
|
||||
},
|
||||
"setting" = message {
|
||||
"name" = "password",
|
||||
"description" = "Password",
|
||||
int32 "type" = 'CSTR',
|
||||
"is_secret" = true
|
||||
},
|
||||
"setting" = message {
|
||||
"name" = "resource",
|
||||
"description" = "Resource",
|
||||
int32 "type" = 'CSTR',
|
||||
"default" = "Caya"
|
||||
}
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
resource app_version {
|
||||
major = 0,
|
||||
middle = 0,
|
||||
minor = 1,
|
||||
|
||||
variety = B_APPV_ALPHA,
|
||||
internal = 0,
|
||||
|
||||
short_info = "GoogleTalk Protocol AddOn for Caya",
|
||||
long_info = "©2010 Pier Luigi Fiorini"
|
||||
};
|
||||
|
||||
resource vector_icon {
|
||||
$"6E636966080501040046020106023E40000000000000003D4000494000470000"
|
||||
$"7EFFFFFFFFE5E1DA02000602000000BBC0004000000000009220244AF0000000"
|
||||
$"33CCFC3366FF02000602000000BA000040000000000092202448800000336699"
|
||||
$"FF6699CC02000602000000B9000040000000000092202448E00000CC0000FFFF"
|
||||
$"000002000602000000BA000040000000000092202448800000FF9900FFFBFF00"
|
||||
$"02000602000000BA000040000000000092202448800000006600FF00CC000A02"
|
||||
$"06C22622C7562239222E342E2B2E3D4146364441483C50404C3C504A444A4E55"
|
||||
$"44CBB634CBB83E5E2A0206C22622C7562239222E342E2B2E3D4146364441483C"
|
||||
$"50404C3C504C464A505744CBB634CBB83E5E2A02024C265928532A583B59335D"
|
||||
$"350610CAFFFEAF375335543B3B5A3B5A395D325D355D2C5D274F275627483241"
|
||||
$"2C413541BDA7C2A83942BDA7C2A8394A3F463F463C40324036402A40234F2346"
|
||||
$"2358325E2A5E395EBF5C5A3F5CBF5C5A3F544053080234313C310404FE372C37"
|
||||
$"393739373A393B383B3A3B3B393B3A3B390406FE0B4536403640363F363E383E"
|
||||
$"373E383E393E393E3A403B3F3B413B453A0405FE03453C453445344533433244"
|
||||
$"324332403240323F323E343E333E3408024D2C4D3C0803553C4F3655300D0A00"
|
||||
$"01001001178400040A020101000A010102000A0101032021210A010204053021"
|
||||
$"2101178200040A0102070630212101178200040A010108301D2101178200040A"
|
||||
$"0102090830212101178200040A030103000A040204051001178200040A050207"
|
||||
$"061001178200040A060108301C2001178200040A07020908100117820004"
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
resource(1000) message('IMst') {
|
||||
"setting" = message {
|
||||
"name" = "username",
|
||||
"description" = "Username",
|
||||
int32 "type" = 'CSTR'
|
||||
},
|
||||
"setting" = message {
|
||||
"name" = "password",
|
||||
"description" = "Password",
|
||||
int32 "type" = 'CSTR',
|
||||
"is_secret" = true
|
||||
},
|
||||
"setting" = message {
|
||||
"name" = "resource",
|
||||
"description" = "Resource",
|
||||
int32 "type" = 'CSTR',
|
||||
"default" = "Caya"
|
||||
}
|
||||
};
|
|
@ -2,12 +2,12 @@
|
|||
resource app_version {
|
||||
major = 0,
|
||||
middle = 0,
|
||||
minor = 0,
|
||||
minor = 1,
|
||||
|
||||
variety = B_APPV_ALPHA,
|
||||
internal = 0,
|
||||
|
||||
short_info = "Jabber Protocol for Caya",
|
||||
short_info = "Jabber Protocol AddOn for Caya",
|
||||
long_info = "©2010 Pier Luigi Fiorini"
|
||||
};
|
||||
|
||||
|
|
Ŝarĝante…
Reference in New Issue