Merged multiprotocol branch with trunk.

This commit is contained in:
plfiorini 2010-05-16 21:02:50 +00:00
parent e1919cd4ac
commit 4bdc37a60e
57 changed files with 2234 additions and 620 deletions

View File

@ -6,7 +6,4 @@ SubInclude TOP application ;
SubInclude TOP protocols ;
SubInclude TOP smileys ;
Distro distro ;
FullDistro fulldistro ;
UninstallTarget $(APPS_DIRECTORY)/caya ;
UninstallTarget $(CAYA_DIRECTORY) ;

View File

@ -11,7 +11,7 @@ PACKAGE_OBJECT_DIR = [ FDirName $(PACKAGE_DIR) objects ] ;
##-------------------------------------------------------------------
## Defines
##-------------------------------------------------------------------
VERSION = 10 ;
VERSION = 0.0.1 ;
DEFINES += VERSION=\"\\\"$(VERSION)\\\"\" ;
DEFINES += BUILD_DATE=\"\\\"$(JAMDATE)\\\"\" ;
CHGRP = ;

View File

@ -1,30 +1,67 @@
/*
* Copyright 2009, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Andrea Anzani, andrea.anzani@gmail.com
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
*/
#include <File.h>
#include <Message.h>
#include <Path.h>
#include "Account.h"
#include "CayaUtils.h"
Account::Account(BHandler* msgTarget)
Account::Account(bigtime_t instanceId, CayaProtocol* cayap,
const char* name, BHandler* target)
: fIdentifier(instanceId),
fName(name),
fProtocol(cayap),
fMessenger(target),
fSettings(new BMessage())
{
BMessenger msgr(msgTarget);
fMessenger = msgr;
fProtocol->Init(this);
// Find user's settings path
BPath path(CayaAccountPath(fProtocol->Signature()));
if (path.InitCheck() == B_OK) {
path.Append(name);
// Load settings file
BFile file(path.Path(), B_READ_ONLY);
if (fSettings->Unflatten(&file) == B_OK)
fProtocol->UpdateSettings(fSettings);
}
}
Account::~Account()
{
delete fSettings;
}
bigtime_t
Account::Identifier() const
{
return fIdentifier;
}
const char*
Account::Name() const
{
return fName.String();
}
status_t
Account::SendMessage(BMessage* message)
{
// This is just an example of what can be done ;)
message->AddPointer("account", (void*)this);
message->AddInt64("instance", fIdentifier);
return fMessenger.SendMessage(message);
}

View File

@ -1,5 +1,6 @@
/*
* Copyright 2009, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _ACCOUNT_H
@ -7,18 +8,27 @@
#include <Handler.h>
#include <Messenger.h>
#include <String.h>
#include "CayaProtocol.h"
class Account : public CayaProtocolMessengerInterface {
public:
Account(BHandler* msgTarget);
virtual ~Account();
Account(bigtime_t instanceId, CayaProtocol* cayap,
const char* name, BHandler* target);
virtual ~Account();
virtual status_t SendMessage(BMessage* message);
bigtime_t Identifier() const;
const char* Name() const;
virtual status_t SendMessage(BMessage* message);
private:
BMessenger fMessenger;
bigtime_t fIdentifier;
CayaProtocol* fProtocol;
BString fName;
BMessenger fMessenger;
BMessage* fSettings;
};
#endif // _ACCOUNT_H

View File

@ -7,6 +7,7 @@
*/
#include "AccountManager.h"
#include "MainWindow.h"
#include "NotifyMessage.h"
#include "Server.h"
#include "TheApp.h"
@ -49,7 +50,7 @@ AccountManager::SetNickname(BString nick)
// Send message
TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
MainWindow* win = theApp->GetMainWindow();
win->GetServer()->SendProtocolMessage(msg);
win->GetServer()->SendAllProtocolMessage(msg);
}
@ -74,7 +75,7 @@ AccountManager::SetStatus(CayaStatus status, const char* str)
// Send message
TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
MainWindow* win = theApp->GetMainWindow();
win->GetServer()->SendProtocolMessage(msg);
win->GetServer()->SendAllProtocolMessage(msg);
// Notify status change
fStatus = status;

View File

@ -0,0 +1,17 @@
/*
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _CAYA_MESSAGES_H
#define _CAYA_MESSAGES_H
//! Open chat window
const uint32 CAYA_OPEN_WINDOW = 'CYow';
//! Close chat window
const uint32 CAYA_CLOSE_WINDOW = 'CYcw';
//! Chat messages
const uint32 CAYA_CHAT = 'CYch';
#endif // _CAYA_MESSAGES_H

View File

@ -1,42 +1,41 @@
/*
* Copyright 2009, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef CayaProtocol_h
#define CayaProtocol_h
#ifndef _CAYA_PROTOCOL_H
#define _CAYA_PROTOCOL_H
#include <Messenger.h>
class CayaProtocolMessengerInterface {
public:
virtual status_t SendMessage(BMessage *message) = 0;
public:
virtual status_t SendMessage(BMessage* message) = 0;
};
class CayaProtocol
{
public:
class CayaProtocol {
public:
// Messenger
virtual status_t Init(CayaProtocolMessengerInterface*) = 0;
// messenger
virtual status_t Init( CayaProtocolMessengerInterface * ) = 0;
// Called before unloading from memory
virtual status_t Shutdown() = 0;
// called before unloading from memory
virtual status_t Shutdown() = 0;
// Process message
virtual status_t Process(BMessage*) = 0;
// process message
virtual status_t Process( BMessage * ) = 0;
// Change settings
virtual status_t UpdateSettings(BMessage*) = 0;
// Get name of protocol
virtual const char * GetSignature() = 0;
virtual const char * GetFriendlySignature() = 0;
// Protocol information
virtual const char* Signature() const = 0;
virtual const char* FriendlySignature() const = 0;
// settings changed
virtual status_t UpdateSettings( BMessage & ) = 0;
// Preferred encoding of messages
virtual uint32 GetEncoding() = 0;
// preferred encoding of messages
virtual uint32 GetEncoding() = 0;
// Messenger interface used
virtual CayaProtocolMessengerInterface* MessengerInterface() const = 0;
};
#endif
#endif // _CAYA_PROTOCOL_H

View File

@ -0,0 +1,100 @@
/*
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Andrea Anzani, andrea.anzani@gmail.com
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
*/
#include <Bitmap.h>
#include <libinterface/BitmapUtils.h>
#include "CayaProtocol.h"
#include "CayaProtocolAddOn.h"
CayaProtocolAddOn::CayaProtocolAddOn(image_id image, const char* path)
: fImage(image),
fPath(path),
fIcon(NULL)
{
_Init();
}
status_t
CayaProtocolAddOn::InitCheck() const
{
return fStatus;
}
const char*
CayaProtocolAddOn::Path() const
{
return fPath.String();
}
CayaProtocol*
CayaProtocolAddOn::Protocol() const
{
return fGetProtocol();
}
const char*
CayaProtocolAddOn::Signature() const
{
return fSignature.String();
}
const char*
CayaProtocolAddOn::FriendlySignature() const
{
return fFriendlySignature.String();
}
BBitmap*
CayaProtocolAddOn::Icon() const
{
return ReadNodeIcon(fPath, B_LARGE_ICON, true);
}
void
CayaProtocolAddOn::_Init()
{
const char* (*signature)();
const char* (*friendly_signature)();
fStatus = B_OK;
if (get_image_symbol(fImage, "protocol", B_SYMBOL_TYPE_TEXT,
(void**)&fGetProtocol) != B_OK) {
unload_add_on(fImage);
fStatus = B_ERROR;
return;
}
if (get_image_symbol(fImage, "signature", B_SYMBOL_TYPE_TEXT,
(void**)&signature) != B_OK) {
unload_add_on(fImage);
fStatus = B_ERROR;
return;
}
if (get_image_symbol(fImage, "friendly_signature", B_SYMBOL_TYPE_TEXT,
(void**)&friendly_signature) != B_OK) {
unload_add_on(fImage);
fStatus = B_ERROR;
return;
}
fSignature = signature();
fFriendlySignature = friendly_signature();
}

View File

@ -0,0 +1,41 @@
/*
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _CAYA_PROTOCOL_ADDON_H
#define _CAYA_PROTOCOL_ADDON_H
#include <image.h>
#include <String.h>
class BBitmap;
class CayaProtocol;
class CayaProtocolAddOn {
public:
CayaProtocolAddOn(image_id image, const char* path);
status_t InitCheck() const;
const char* Path() const;
CayaProtocol* Protocol() const;
const char* Signature() const;
const char* FriendlySignature() const;
BBitmap* Icon() const;
private:
image_id fImage;
BString fPath;
CayaProtocol* (*fGetProtocol)();
BString fSignature;
BString fFriendlySignature;
BBitmap* fIcon;
status_t fStatus;
void _Init();
};
#endif // _CAYA_PROTOCOL_ADDON_H

View File

@ -22,6 +22,7 @@
#include <ScrollView.h>
#include <String.h>
#include "CayaMessages.h"
#include "ChatWindow.h"
#include "ContactLinker.h"
#include "EditingFilter.h"
@ -29,9 +30,6 @@
#include "CayaRenderView.h"
#include "NotifyMessage.h"
const int32 kCloseWindow = 'clwn';
const int32 kChat = 'chat';
ChatWindow::ChatWindow(ContactLinker* cl)
: BWindow(BRect(200, 200, 500, 500),
@ -68,9 +66,9 @@ ChatWindow::ChatWindow(ContactLinker* cl)
bool
ChatWindow::QuitRequested()
{
BMessage msg(kCloseWindow);
BMessage msg(CAYA_CLOSE_WINDOW);
msg.AddString("id", fContactLinker->GetId());
fContactLinker->GetMessenger().SendMessage(&msg);
fContactLinker->Messenger().SendMessage(&msg);
return false;
}
@ -79,7 +77,7 @@ void
ChatWindow::MessageReceived(BMessage* message)
{
switch(message->what) {
case kChat:
case CAYA_CHAT:
{
BString message = fSendView->Text();
if (message == "")
@ -91,7 +89,7 @@ ChatWindow::MessageReceived(BMessage* message)
msg.AddInt32("im_what", IM_SEND_MESSAGE);
msg.AddString("id", fContactLinker->GetId());
msg.AddString("message", message);
fContactLinker->GetMessenger().SendMessage(&msg);
fContactLinker->Messenger().SendMessage(&msg);
fSendView->SetText("");
break;
@ -178,6 +176,7 @@ ChatWindow::ImMessage(BMessage* msg)
}
}
void
ChatWindow::ObserveString(int32 what, BString str)
{

View File

@ -8,6 +8,7 @@
#include <stdio.h>
#include "CayaProtocolAddOn.h"
#include "ChatWindow.h"
#include "ContactLinker.h"
#include "ContactPopUp.h"
@ -22,6 +23,7 @@ ContactLinker::ContactLinker(BString id, BMessenger msgn)
fID(id),
fName(id),
fMessenger(msgn),
fLooper(NULL),
fStatus(CAYA_OFFLINE),
fPopUp(NULL)
{
@ -30,7 +32,8 @@ ContactLinker::ContactLinker(BString id, BMessenger msgn)
RegisterObserver(fRosterItem);
// By default we use protocol icon as avatar icon
fAvatarBitmap = ProtocolManager::Get()->GetProtocolIcon("aim");
CayaProtocolAddOn* addOn = ProtocolManager::Get()->ProtocolAddOn("gtalk");
fAvatarBitmap = addOn->Icon();
}
@ -111,6 +114,35 @@ ContactLinker::DeletePopUp()
}
BMessenger
ContactLinker::Messenger() const
{
return fMessenger;
}
void
ContactLinker::SetMessenger(BMessenger messenger)
{
fMessenger = messenger;
}
ProtocolLooper*
ContactLinker::GetProtocolLooper() const
{
return fLooper;
}
void
ContactLinker::SetProtocolLooper(ProtocolLooper* looper)
{
if (looper)
fLooper = looper;
}
void
ContactLinker::SetNotifyName(BString name)
{

View File

@ -16,6 +16,7 @@ class BBitmap;
class ChatWindow;
class ContactPopUp;
class ProtocolLooper;
class RosterItem;
class ContactLinker : public Notifier {
@ -36,7 +37,11 @@ public:
BString GetId() { return fID; }
BMessenger GetMessenger() { return fMessenger; }
BMessenger Messenger() const;
void SetMessenger(BMessenger messenger);
ProtocolLooper* GetProtocolLooper() const;
void SetProtocolLooper(ProtocolLooper* looper);
BString GetName() { return fName; }
BBitmap* AvatarBitmap() { return fAvatarBitmap; }
@ -52,8 +57,10 @@ private:
RosterItem* fRosterItem;
ChatWindow* fChatWindow;
BMessenger fMessenger;
ProtocolLooper* fLooper;
BString fID;
bigtime_t fInstance;
BString fName;
BString fPersonalStatus;
BBitmap* fAvatarBitmap;

View File

@ -10,6 +10,7 @@
#include <Message.h>
#include <Window.h>
#include "CayaMessages.h"
#include "EditingFilter.h"
@ -37,7 +38,7 @@ EditingFilter::Filter(BMessage* message, BHandler** target)
_view->Insert("\n");
return B_SKIP_MESSAGE;
} else if ((modifiers & B_COMMAND_KEY) == 0 && byte == B_ENTER) {
_view->Window()->PostMessage('chat');
_view->Window()->PostMessage(CAYA_CHAT);
return B_SKIP_MESSAGE;
}

View File

@ -15,19 +15,20 @@ local svnRevisionFile = [ FGristFiles svn_revision ] ;
MakeLocate $(svnRevisionFile) : $(LOCATE_TARGET) ;
CreateSVNRevisionFile $(svnRevisionFile) ;
Application caya :
Application Caya :
AboutWindow.cpp
Account.cpp
AccountManager.cpp
CayaProtocolAddOn.cpp
CayaUtils.cpp
ChatWindow.cpp
ContactLinker.cpp
EditingFilter.cpp
ImageCache.cpp
LooperCayaProtocol.cpp
Main.cpp
MainWindow.cpp
Notifier.cpp
ProtocolLooper.cpp
ProtocolManager.cpp
ProtocolSettings.cpp
Server.cpp
@ -56,10 +57,10 @@ Application caya :
: Caya.rdef
;
Depends caya : libjabber.a ;
Depends caya : librunview.a ;
Depends caya : libinterface.a ;
Depends Caya : libjabber.a ;
Depends Caya : librunview.a ;
Depends Caya : libinterface.a ;
LINKFLAGS on caya += -L$(OPENSSL_LIBRARY_DIR) ;
LINKFLAGS on Caya += -L$(OPENSSL_LIBRARY_DIR) ;
InstallBin $(APPS_DIRECTORY)/caya : caya ;
InstallBin $(CAYA_DIRECTORY) : Caya ;

View File

@ -1,37 +0,0 @@
/*
* Copyright 2009, Andrea Anzani. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Andrea Anzani, andrea.anzani@gmail.com
*/
#include <String.h>
#include "LooperCayaProtocol.h"
LooperCayaProtocol::LooperCayaProtocol(CayaProtocol* protocol)
: BLooper(),
fProtocol(protocol)
{
BString name("CayaProcol - ");
name << protocol->GetFriendlySignature();
SetName(name.String());
Run();
}
void
LooperCayaProtocol::MessageReceived(BMessage* msg)
{
if (Protocol()->Process(msg) != B_OK)
BLooper::MessageReceived(msg);
}
CayaProtocol*
LooperCayaProtocol::Protocol()
{
return fProtocol;
}

View File

@ -1,25 +0,0 @@
/*
* Copyright 2009, Andrea Anzani. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef LooperCayaProtocol_h
#define LooperCayaProtocol_h
#include <Looper.h>
#include "CayaProtocol.h"
class LooperCayaProtocol : public BLooper
{
public:
LooperCayaProtocol(CayaProtocol* protocol);
void MessageReceived(BMessage* msg);
CayaProtocol* Protocol();
private:
CayaProtocol* fProtocol;
};
#endif

View File

@ -32,6 +32,7 @@
#include <libinterface/ToolButton.h>
#include "CayaConstants.h"
#include "CayaMessages.h"
#include "CayaResources.h"
#include "CayaUtils.h"
#include "NotifyMessage.h"
@ -48,38 +49,16 @@ const uint32 kSearchContact = 'SRCH';
const uint32 kPreferences = 'WPRF';
MainWindow::MainWindow() :
BWindow(BRect(0, 0, 300, 400), "Caya", B_DOCUMENT_WINDOW, 0)
MainWindow::MainWindow()
: BWindow(BRect(0, 0, 300, 400), "Caya", B_DOCUMENT_WINDOW, 0)
{
SetLayout(fStack = new BCardLayout());
BBox* loginView = new BBox("loginView");
BButton* login = new BButton(BRect(294.0, 302.0, 392.0, 328.0), "login",
"Login", new BMessage(kLogin), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT);
loginView->SetLayout(new BGroupLayout(B_HORIZONTAL));
loginView->AddChild(BGroupLayoutBuilder(B_VERTICAL, 5)
.Add(BGridLayoutBuilder(10, 10)
.Add(new BStringView("label_u", "Username"), 0, 0)
.Add(fUsername = new BTextControl("username", NULL, NULL, NULL), 1, 0)
.Add(new BStringView("label_p", "Password"), 0, 1)
.Add(fPassword = new BTextControl("password", NULL, NULL,
new BMessage(kLogin)), 1, 1), 2)
.Add(login, 3)
);
fStack->AddView(loginView);
fStatusView = new StatusView("statusView");
BTextControl* searchBox = new BTextControl("searchBox", NULL, NULL,
new BMessage(kSearchContact));
BBox* rosterView = new BBox("rosterView");
fListView = new RosterListView("buddyView");
fListView->SetInvocationMessage(new BMessage(OPEN_WINDOW));
fListView->SetInvocationMessage(new BMessage(CAYA_OPEN_WINDOW));
BScrollView* scrollView = new BScrollView("scrollview", fListView,
B_WILL_DRAW, false, true);
@ -105,8 +84,8 @@ MainWindow::MainWindow() :
wrench->SetBitmap(toolIcon);
wrench->SetMenu(wrenchMenu);
rosterView->SetLayout(new BGridLayout(5, 5));
rosterView->AddChild(BGridLayoutBuilder(5, 0)
SetLayout(new BGridLayout(5, 5));
AddChild(BGridLayoutBuilder(5, 5)
.Add(fStatusView, 0, 0)
.Add(wrench, 1, 0)
.Add(searchBox, 0, 1)
@ -114,27 +93,30 @@ MainWindow::MainWindow() :
.SetInsets(5, 5, 5, 10)
);
fStack->AddView(rosterView);
fStack->SetVisibleItem((long)0);
AddShortcut('a', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED));
MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));
fPassword->TextView()->HideTyping(true);
fUsername->MakeFocus(true);
fSrv = new Server(this);
AddFilter(fSrv);
// Filter messages using Server
fServer = new Server();
AddFilter(fServer);
CenterOnScreen();
}
void
MainWindow::Start()
{
// Login all accounts
fServer->LoginAll();
}
bool
MainWindow::QuitRequested()
{
fListView->MakeEmpty();
fSrv->Quit();
fServer->Quit();
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
@ -143,27 +125,8 @@ MainWindow::QuitRequested()
void
MainWindow::MessageReceived(BMessage* message)
{
switch(message->what) {
case kLogin:
{
BString username(fUsername->Text());
BString password(fPassword->Text());
if (username == "" || password == "")
return;
BMessage config;
config.AddString("username", username);
config.AddString("password", password);
config.AddString("resource", "caya");
fSrv->UpdateSettings(config);
fSrv->Login();
fStack->SetVisibleItem((long)1);
break;
}
case kSearchContact:
{
switch (message->what) {
case kSearchContact: {
void* control = NULL;
if (message->FindPointer("source", &control) != B_OK)
return;
@ -172,7 +135,7 @@ MainWindow::MessageReceived(BMessage* message)
if (searchBox == NULL)
return;
RosterMap map = fSrv->RosterItems();
RosterMap map = fServer->RosterItems();
for (uint32 i = 0; i < map.CountItems(); i++) {
ContactLinker* linker = map.ValueAt(i);
RosterItem* item = linker->GetRosterItem();
@ -195,6 +158,13 @@ MainWindow::MessageReceived(BMessage* message)
dialog->Show();
break;
}
case CAYA_OPEN_WINDOW: {
int index = message->FindInt32("index");
RosterItem* ritem = ItemAt(index);
if (ritem != NULL)
ritem->GetContactLinker()->ShowWindow();
break;
}
case IM_MESSAGE:
ImMessage(message);
break;
@ -209,20 +179,21 @@ MainWindow::MessageReceived(BMessage* message)
}
}
void
MainWindow::ImError(BMessage* msg)
{
//FIXME: better error handling..
BAlert* alert = new BAlert("Error", msg->FindString("error"), "Ouch!");
alert->Go();
fStack->SetVisibleItem((long)0);
}
void
MainWindow::ImMessage(BMessage* msg)
{
int32 im_what = msg->FindInt32("im_what");
switch(im_what) {
switch (im_what) {
case IM_OWN_CONTACT_INFO:
{
fStatusView->SetName(msg->FindString("nick"));
@ -241,7 +212,7 @@ MainWindow::ImMessage(BMessage* msg)
if (msg->FindInt32("status", &status) != B_OK)
return;
RosterItem* rosterItem = fSrv->RosterItemForId(msg->FindString("id"));
RosterItem* rosterItem = fServer->RosterItemForId(msg->FindString("id"));
if (rosterItem) {
// Add or remove item
@ -266,7 +237,7 @@ MainWindow::ImMessage(BMessage* msg)
case IM_AVATAR_CHANGED:
case IM_CONTACT_INFO:
{
RosterItem* rosterItem = fSrv->RosterItemForId(msg->FindString("id"));
RosterItem* rosterItem = fServer->RosterItemForId(msg->FindString("id"));
if (rosterItem)
UpdateListItem(rosterItem);
break;

View File

@ -18,13 +18,12 @@ class StatusView;
class RosterListView;
class RosterItem;
#define OPEN_WINDOW 'opwn'
#define CLOSE_WINDOW 'clwn'
class MainWindow: public BWindow, public Observer {
public:
MainWindow();
void Start();
virtual void MessageReceived(BMessage* message);
void ImMessage(BMessage* msg);
void ImError(BMessage* msg);
@ -32,7 +31,7 @@ public:
void ObserveInteger(int32 what, int32 val);
Server* GetServer() const { return fSrv; }
Server* GetServer() const { return fServer; }
void UpdateListItem(RosterItem* item);
@ -45,10 +44,7 @@ public:
private:
StatusView* fStatusView;
RosterListView* fListView;
BCardLayout* fStack;
BTextControl* fUsername;
BTextControl* fPassword;
Server* fSrv;
Server* fServer;
};
#endif // _MAIN_WINDOW_H

View File

@ -0,0 +1,44 @@
/*
* Copyright 2009-2010, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Andrea Anzani, andrea.anzani@gmail.com
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
*/
#include <String.h>
#include "Account.h"
#include "ProtocolLooper.h"
ProtocolLooper::ProtocolLooper(CayaProtocol* protocol)
: BLooper(),
fProtocol(protocol)
{
Account* account = reinterpret_cast<Account*>(
protocol->MessengerInterface());
BString name(protocol->FriendlySignature());
name << " - " << account->Name();
SetName(name.String());
Run();
}
void
ProtocolLooper::MessageReceived(BMessage* msg)
{
if (Protocol()->Process(msg) != B_OK)
BLooper::MessageReceived(msg);
}
CayaProtocol*
ProtocolLooper::Protocol()
{
return fProtocol;
}

View File

@ -0,0 +1,25 @@
/*
* Copyright 2009-2010, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _PROTOCOL_LOOPER_H
#define _PROTOCOL_LOOPER_H
#include <Looper.h>
#include "CayaProtocol.h"
class ProtocolLooper : public BLooper {
public:
ProtocolLooper(CayaProtocol* protocol);
void MessageReceived(BMessage* msg);
CayaProtocol* Protocol();
private:
CayaProtocol* fProtocol;
};
#endif // _PROTOCOL_LOOPER_H

View File

@ -7,47 +7,43 @@
*/
#include <stdio.h>
#include <Entry.h>
#include <image.h>
#include <libinterface/BitmapUtils.h>
#include <Directory.h>
#include <Entry.h>
#include <Handler.h>
#include "Account.h"
#include "ProtocolManager.h"
#include "CayaProtocol.h"
#include "CayaUtils.h"
#include "MainWindow.h"
#include "Server.h"
#include "TheApp.h"
static ProtocolManager* fInstance = NULL;
void
ProtocolManager::Init(BDirectory protocolDir)
ProtocolManager::Init(BDirectory dir, BHandler* target)
{
BEntry entry;
BPath path;
protocolDir.Rewind();
dir.Rewind();
while (protocolDir.GetNextEntry(&entry) == B_OK) {
while (dir.GetNextEntry(&entry) == B_OK) {
path = BPath(&entry);
// Load protocol addon
image_id id = load_add_on(path.Path());
if (id >= 0) {
CayaProtocol* (*main_protocol)();
if (get_image_symbol(id, "main_protocol", B_SYMBOL_TYPE_TEXT,
(void**)&main_protocol) == B_OK) {
CayaProtocol* cayp = (*main_protocol)();
if (id < 0)
continue;
if (cayp) {
printf("Found a new Protocol: %s [%s]\n", cayp->GetFriendlySignature(),
cayp->GetSignature());
fProtocolMap.AddItem(BString(cayp->GetSignature()), cayp);
fAddonMap.AddItem(BString(cayp->GetSignature()), new BPath(path));
} else
unload_add_on(id);
} else
unload_add_on(id);
}
CayaProtocolAddOn* addOn = new CayaProtocolAddOn(id, path.Path());
fAddOnMap.AddItem(addOn->Signature(), addOn);
_GetAccounts(addOn, target);
}
}
@ -66,30 +62,69 @@ ProtocolManager::Get()
}
ProtocolAddOns
ProtocolManager::Protocols()
{
return fAddOnMap.Values();
}
ProtocolMap
ProtocolManager::ProtocolInstances() const
{
return fProtocolMap;
}
CayaProtocol*
ProtocolManager::GetProtocol(BString signature)
ProtocolManager::ProtocolInstance(bigtime_t identifier)
{
return fProtocolMap.ValueFor(signature);
return fProtocolMap.ValueFor(identifier);
}
BList*
ProtocolManager::GetProtocols()
CayaProtocolAddOn*
ProtocolManager::ProtocolAddOn(const char* signature)
{
return fProtocolMap.Items();
return fAddOnMap.ValueFor(signature);
}
BPath*
ProtocolManager::GetProtocolPath(BString signature)
void
ProtocolManager::AddAccount(CayaProtocolAddOn* addOn, const char* account,
BHandler* target)
{
return fAddonMap.ValueFor(signature);
bigtime_t instanceId = system_time();
CayaProtocol* cayap = addOn->Protocol();
(void)new Account(instanceId, cayap, account, target);
fProtocolMap.AddItem(instanceId, cayap);
TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
theApp->GetMainWindow()->GetServer()->AddProtocolLooper(
instanceId, cayap);
}
BBitmap*
ProtocolManager::GetProtocolIcon(BString signature)
void
ProtocolManager::_GetAccounts(CayaProtocolAddOn* addOn, BHandler* target)
{
BPath* path = fAddonMap.ValueFor(signature);
return ReadNodeIcon(path->Path(), B_LARGE_ICON, true);
// Find accounts path for this protocol
BPath path(CayaAccountPath(addOn->Signature()));
if (path.InitCheck() != B_OK)
return;
BDirectory dir(path.Path());
BEntry entry;
while (dir.GetNextEntry(&entry) == B_OK) {
BFile file(&entry, B_READ_ONLY);
BMessage msg;
if (msg.Unflatten(&file) == B_OK) {
char buffer[B_PATH_NAME_LENGTH];
if (entry.GetName(buffer) == B_OK) {
printf("Found %s for protocol %s!\n", buffer, addOn->Signature());
AddAccount(addOn, buffer, target);
}
}
}
}

View File

@ -1,38 +1,49 @@
/*
* Copyright 2009, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef ProtocolManager_h
#define ProtocolManager_h
#ifndef _PROTOCOL_MANAGER_H
#define _PROTOCOL_MANAGER_H
#include <Directory.h>
#include <Path.h>
#include <String.h>
#include <libs/libsupport/KeyMap.h>
#include <libsupport/KeyMap.h>
#include "CayaProtocol.h"
#include "CayaProtocolAddOn.h"
class BBitmap;
class BDirectory;
class BHandler;
class ProtocolManager
{
typedef List<CayaProtocolAddOn*> ProtocolAddOns;
typedef KeyMap<BString, CayaProtocolAddOn*> AddOnMap;
typedef KeyMap<bigtime_t, CayaProtocol*> ProtocolMap;
class ProtocolManager {
public:
void Init(BDirectory protocolDir);
static ProtocolManager* Get();
void Init(BDirectory dir, BHandler* target);
CayaProtocol* GetProtocol(BString signature);
static ProtocolManager* Get();
BList* GetProtocols();
ProtocolAddOns Protocols();
ProtocolMap ProtocolInstances() const;
BPath* GetProtocolPath(BString signature);
BBitmap* GetProtocolIcon(BString signature);
CayaProtocol* ProtocolInstance(bigtime_t identifier);
CayaProtocolAddOn* ProtocolAddOn(const char* signature);
private:
void AddAccount(CayaProtocolAddOn* addOn,
const char* account,
BHandler* target);
ProtocolManager();
private:
ProtocolManager();
void _GetAccounts(CayaProtocolAddOn* addOn, BHandler* target);
KeyMap<BString, CayaProtocol*> fProtocolMap;
KeyMap<BString, BPath*> fAddonMap;
AddOnMap fAddOnMap;
ProtocolMap fProtocolMap;
};
#endif
#endif // _PROTOCOL_MANAGER_H

View File

@ -31,7 +31,7 @@
#include <libinterface/NotifyingTextView.h>
#include "CayaProtocol.h"
#include "CayaProtocolAddOn.h"
#include "CayaResources.h"
#include "CayaUtils.h"
#include "ProtocolManager.h"
@ -42,8 +42,8 @@
const float kDividerWidth = 1.0f;
ProtocolSettings::ProtocolSettings(CayaProtocol* cayap)
: fProtocol(cayap),
ProtocolSettings::ProtocolSettings(CayaProtocolAddOn* addOn)
: fAddOn(addOn),
fTemplate(new BMessage())
{
_Init();
@ -63,10 +63,10 @@ ProtocolSettings::InitCheck() const
}
CayaProtocol*
ProtocolSettings::Protocol() const
CayaProtocolAddOn*
ProtocolSettings::AddOn() const
{
return fProtocol;
return fAddOn;
}
@ -75,7 +75,7 @@ ProtocolSettings::Accounts() const
{
List<BString> list;
BPath path(CayaAccountPath(fProtocol->GetSignature()));
BPath path(CayaAccountPath(fAddOn->Signature()));
if (path.InitCheck() != B_OK)
return list;
@ -155,21 +155,19 @@ ProtocolSettings::Load(const char* account, BView* parent)
menu->AddItem(item);
}
if (settings) {
if (settings)
value = settings->FindString(name);
if (value)
menu->FindItem(value)->SetMarked(true);
}
if (value)
menu->FindItem(value)->SetMarked(true);
} else {
// It's a free-text setting
if (curr.FindBool("multi_line", &multiLine) != B_OK)
multiLine = false;
if (settings) {
if (settings)
value = settings->FindString(name);
if (!value)
value = curr.FindString("default");
}
if (!value)
value = curr.FindString("default");
if (curr.FindBool("is_secret",&secret) != B_OK)
secret = false;
@ -354,13 +352,34 @@ ProtocolSettings::Save(const char* account, BView* parent)
}
status_t
ProtocolSettings::Rename(const char* from, const char* to)
{
status_t ret = B_ERROR;
// Find user's settings path
BPath path(CayaAccountPath(fAddOn->Signature()));
if ((ret = path.InitCheck()) != B_OK)
return ret;
path.Append(from);
// Delete settings file
BEntry entry(path.Path());
if ((ret = entry.Rename(to)) != B_OK)
return ret;
return B_OK;
}
status_t
ProtocolSettings::Delete(const char* account)
{
status_t ret = B_ERROR;
// Find user's settings path
BPath path(CayaAccountPath(fProtocol->GetSignature()));
BPath path(CayaAccountPath(fAddOn->Signature()));
if ((ret = path.InitCheck()) != B_OK)
return ret;
@ -379,9 +398,8 @@ void
ProtocolSettings::_Init()
{
// Find protocol add-on
BPath* dllPath = ProtocolManager::Get()->GetProtocolPath(
fProtocol->GetSignature());
BFile file(dllPath->Path(), B_READ_ONLY);
BPath dllPath(fAddOn->Path());
BFile file(dllPath.Path(), B_READ_ONLY);
if (file.InitCheck() < B_OK) {
fStatus = file.InitCheck();
return;
@ -417,7 +435,7 @@ ProtocolSettings::_Load(const char* account, BMessage** settings)
status_t ret = B_ERROR;
// Find user's settings path
BPath path(CayaAccountPath(fProtocol->GetSignature()));
BPath path(CayaAccountPath(fAddOn->Signature()));
if ((ret = path.InitCheck()) != B_OK)
return ret;
@ -440,7 +458,7 @@ ProtocolSettings::_Save(const char* account, BMessage* settings)
status_t ret = B_ERROR;
// Find user's settings path
BPath path(CayaAccountPath(fProtocol->GetSignature()));
BPath path(CayaAccountPath(fAddOn->Signature()));
if ((ret = path.InitCheck()) != B_OK)
return ret;

View File

@ -9,26 +9,28 @@
#include <libsupport/List.h>
class BMessage;
class CayaProtocol;
class CayaProtocolAddOn;
class ProtocolSettings {
public:
ProtocolSettings(CayaProtocol* cayap);
ProtocolSettings(CayaProtocolAddOn* addOn);
~ProtocolSettings();
status_t InitCheck() const;
CayaProtocol* Protocol() const;
CayaProtocolAddOn* AddOn() const;
List<BString> Accounts() const;
status_t LoadTemplate(BView* parent);
status_t Load(const char* account, BView* parent);
status_t Save(const char* account, BView* parent);
status_t Rename(const char* from, const char* to);
status_t Delete(const char* account);
private:
status_t fStatus;
CayaProtocol* fProtocol;
CayaProtocolAddOn* fAddOn;
BString fAccount;
BMessage* fTemplate;

View File

@ -1,5 +1,6 @@
/*
* Copyright 2009, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -8,36 +9,26 @@
*/
#include <Application.h>
#include <Debug.h>
#include <Entry.h>
#include <Path.h>
#include <TranslationUtils.h>
#include "AccountManager.h"
#include "ImageCache.h"
#include "LooperCayaProtocol.h"
#include "ProtocolManager.h"
#include "Server.h"
#include "MainWindow.h"
#include "RosterItem.h"
#include "ChatWindow.h"
#include <Debug.h>
#include "Account.h"
#include "AccountManager.h"
#include "ProtocolLooper.h"
#include "CayaMessages.h"
#include "CayaProtocol.h"
#include "ChatWindow.h"
#include "ImageCache.h"
#include "ProtocolManager.h"
#include "RosterItem.h"
#include "Server.h"
Server::Server(MainWindow* mainWindow)
Server::Server()
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE)
{
CayaProtocol* pp = ProtocolManager::Get()->GetProtocol("aim");
if (!pp)
debugger("something wrong");
//FIXME: here just a first draft of the final design:
Account* gtalkAccount = new Account(mainWindow);
pp->Init(gtalkAccount);
fMainWindow = mainWindow;
fProtocol = new LooperCayaProtocol(pp);
}
@ -45,6 +36,7 @@ void
Server::Quit()
{
ContactLinker* linker = NULL;
while ((linker = fRosterMap.ValueAt(0))) {
linker->DeleteWindow();
linker->DeletePopUp();
@ -54,27 +46,74 @@ Server::Quit()
void
Server::Login()
Server::AddProtocolLooper(bigtime_t instanceId, CayaProtocol* cayap)
{
BMessage* msg = new BMessage(IM_MESSAGE);
msg->AddInt32("im_what", IM_SET_STATUS);
msg->AddInt32("status", CAYA_ONLINE);
fProtocol->PostMessage(msg);
ProtocolLooper* looper = new ProtocolLooper(cayap);
fLoopers.AddItem(instanceId, looper);
}
void
Server::RemoveProtocolLooper(bigtime_t instanceId)
{
}
void
Server::LoginAll()
{
for (uint32 i = 0; i < fLoopers.CountItems(); i++) {
ProtocolLooper* looper = fLoopers.ValueAt(i);
BMessage* msg = new BMessage(IM_MESSAGE);
msg->AddInt32("im_what", IM_SET_STATUS);
msg->AddInt32("status", CAYA_ONLINE);
looper->PostMessage(msg);
}
}
#if 0
void
Server::UpdateSettings(BMessage settings)
{
fProtocol->Protocol()->UpdateSettings(settings);
}
#endif
void
Server::SendProtocolMessage(BMessage* msg)
{
if (msg != NULL)
fProtocol->PostMessage(msg);
// Skip null messages
if (!msg)
return;
// Check if message contains the instance field
bigtime_t id;
if (msg->FindInt64("instance", &id) == B_OK) {
bool found = false;
ProtocolLooper* looper
= fLoopers.ValueFor(id, &found);
if (found)
looper->PostMessage(msg);
}
}
void
Server::UpdateSettings(BMessage settings)
Server::SendAllProtocolMessage(BMessage* msg)
{
fProtocol->Protocol()->UpdateSettings(settings);
// Skip null messages
if (!msg)
return;
// Send message to all protocols
for (uint32 i = 0; i < fLoopers.CountItems(); i++) {
ProtocolLooper* looper = fLoopers.ValueAt(i);
looper->PostMessage(msg);
}
}
@ -92,27 +131,35 @@ Server::Filter(BMessage* message, BHandler **target)
bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found);
if (!found) {
item = new ContactLinker(id.String(), Looper());
fRosterMap.AddItem(id, item);
if (found)
continue;
item = new ContactLinker(id.String(), Looper());
item->SetProtocolLooper(_LooperFromMessage(message));
fRosterMap.AddItem(id, item);
}
result = B_SKIP_MESSAGE;
break;
}
case IM_MESSAGE_RECEIVED:
{
BString id = message->FindString("id");
if (id.Length() > 0) {
bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found);
if (found) {
ChatWindow* win = item->GetChatWindow();
item->ShowWindow();
win->PostMessage(message);
}
}
result = B_SKIP_MESSAGE;
break;
}
case OPEN_WINDOW:
{
int index = message->FindInt32("index");
RosterItem* ritem = fMainWindow->ItemAt(index);
if (ritem != NULL)
ritem->GetContactLinker()->ShowWindow();
result = B_SKIP_MESSAGE;
break;
}
case CLOSE_WINDOW:
case CAYA_CLOSE_WINDOW:
{
BString id = message->FindString("id");
if (id != "") {
if (id.Length() > 0) {
bool found = false;
ContactLinker *item = fRosterMap.ValueFor(id, &found);
@ -125,6 +172,9 @@ Server::Filter(BMessage* message, BHandler **target)
case IM_MESSAGE:
result = ImMessage(message);
break;
default:
// Dispatch not handled messages to main window
break;
}
return result;
@ -175,14 +225,15 @@ Server::ImMessage(BMessage* msg)
if (msg->FindInt32("status", &status) != B_OK)
return B_SKIP_MESSAGE;
ContactLinker* linker = EnsureContactLinker(msg->FindString("id"));
ContactLinker* linker = _EnsureContactLinker(msg);
linker->SetNotifyStatus((CayaStatus)status);
linker->SetNotifyPersonalStatus(msg->FindString("message"));
break;
}
case IM_CONTACT_INFO:
{
ContactLinker* linker = EnsureContactLinker(msg->FindString("id"));
ContactLinker* linker = _EnsureContactLinker(msg);
BString fullName = msg->FindString("nick");
if (fullName != "")
linker->SetNotifyName(fullName);
@ -190,7 +241,7 @@ Server::ImMessage(BMessage* msg)
}
case IM_AVATAR_CHANGED:
{
ContactLinker* linker = EnsureContactLinker(msg->FindString("id"));
ContactLinker* linker = _EnsureContactLinker(msg);
entry_ref ref;
if (linker) {
if (msg->FindRef("ref", &ref) == B_OK) {
@ -203,13 +254,17 @@ Server::ImMessage(BMessage* msg)
}
break;
}
case IM_SEND_MESSAGE:
fProtocol->PostMessage(msg);
case IM_SEND_MESSAGE: {
// Route this message through the appropriate ProtocolLooper
ContactLinker* linker = _EnsureContactLinker(msg);
if (linker->GetProtocolLooper())
linker->GetProtocolLooper()->PostMessage(msg);
break;
}
case IM_MESSAGE_RECEIVED:
{
BString id = msg->FindString("id");
if (id != "") {
if (id.Length() > 0) {
bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found);
if (found) {
@ -222,7 +277,6 @@ Server::ImMessage(BMessage* msg)
break;
}
default:
msg->PrintToStream();
break;
}
@ -231,24 +285,51 @@ Server::ImMessage(BMessage* msg)
ContactLinker*
Server::EnsureContactLinker(BString id)
Server::GetOwnContact()
{
return fMySelf;
}
ProtocolLooper*
Server::_LooperFromMessage(BMessage* message)
{
if (!message)
return NULL;
bigtime_t identifier;
if (message->FindInt64("instance", &identifier) == B_OK) {
bool found = false;
ProtocolLooper* looper = fLoopers.ValueFor(identifier, &found);
if (found)
return looper;
}
return NULL;
}
ContactLinker*
Server::_EnsureContactLinker(BMessage* message)
{
if (!message)
return NULL;
BString id = message->FindString("id");
ContactLinker* item = NULL;
if (id != "") {
if (id.Length() > 0) {
bool found = false;
item = fRosterMap.ValueFor(id, &found);
if (!found) {
item = new ContactLinker(id.String(), Looper());
item->SetProtocolLooper(_LooperFromMessage(message));
fRosterMap.AddItem(id, item);
}
}
return item;
}
ContactLinker*
Server::GetOwnContact()
{
return fMySelf;
}

View File

@ -1,5 +1,6 @@
/*
* Copyright 2009, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Andrea Anzani. All rights reserved.
* Copyright 2009-2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SERVER_H
@ -13,40 +14,46 @@
#include "CayaConstants.h"
#include "ContactLinker.h"
class MainWindow;
class CayaProtocol;
class RosterItem;
class LooperCayaProtocol;
class ProtocolLooper;
typedef KeyMap<BString, ContactLinker*> RosterMap;
typedef KeyMap<bigtime_t, ProtocolLooper*> ProtocolLoopers;
class Server: public BMessageFilter {
public:
Server(MainWindow* mainWindow);
Server();
virtual filter_result Filter(BMessage* message, BHandler** target);
filter_result ImMessage(BMessage* msg);
void UpdateSettings(BMessage settings);
void Quit();
void Login();
void AddProtocolLooper(bigtime_t instanceId, CayaProtocol* cayap);
void RemoveProtocolLooper(bigtime_t instanceId);
void LoginAll();
#if 0
void UpdateSettings(BMessage settings);
#endif
void SendProtocolMessage(BMessage* msg);
void SendChatMessage(BMessage* msg);
void SendAllProtocolMessage(BMessage* msg);
RosterMap RosterItems() const;
RosterItem* RosterItemForId(BString id);
void Quit();
//TODO: there should be a contact for each account.
ContactLinker* GetOwnContact();
private:
ContactLinker* EnsureContactLinker(BString id);
ProtocolLooper* _LooperFromMessage(BMessage* message);
ContactLinker* _EnsureContactLinker(BMessage* message);
RosterMap fRosterMap;
MainWindow* fMainWindow;
LooperCayaProtocol* fProtocol;
ProtocolLoopers fLoopers;
ContactLinker* fMySelf;
};

View File

@ -16,11 +16,12 @@
#include "AboutWindow.h"
#include "Caya.h"
#include "TheApp.h"
#include "Emoticor.h"
#include "FilePanel.h"
#include "MainWindow.h"
#include "Emoticor.h"
#include "ProtocolManager.h"
#include "Server.h"
#include "TheApp.h"
#include "svn_revision.h"
@ -37,13 +38,18 @@ TheApp::ReadyToRun()
{
app_info theInfo;
if (be_app->GetAppInfo(&theInfo) == B_OK) {
BPath applicationDirectory(&theInfo.ref);
applicationDirectory.GetParent(&applicationDirectory);
fMainWin = new MainWindow();
BPath currentPath = applicationDirectory;
if (be_app->GetAppInfo(&theInfo) == B_OK) {
BPath appDir(&theInfo.ref);
appDir.GetParent(&appDir);
// Emoticons settings
BPath currentPath = appDir;
currentPath.Append("smileys");
currentPath.Append("settings.xml");
// Load emoticons
BEntry entry(currentPath.Path());
if (entry.Exists())
Emoticor::Get()->LoadConfig(currentPath.Path());
@ -55,11 +61,13 @@ TheApp::ReadyToRun()
}
printf("Loaded Emoticons settings from: %s\n", currentPath.Path());
currentPath = applicationDirectory;
currentPath = appDir;
currentPath.Append("protocols");
if (BEntry(currentPath.Path()).Exists()) {
printf("Looking for protocols from: %s\n", currentPath.Path());
ProtocolManager::Get()->Init(BDirectory(currentPath.Path()));
ProtocolManager::Get()->Init(BDirectory(currentPath.Path()),
fMainWin);
} else {
BString msg("Can't find protocols in:\n\n");
msg << currentPath.Path();
@ -70,7 +78,7 @@ TheApp::ReadyToRun()
}
}
fMainWin = new MainWindow();
fMainWin->Start();
fMainWin->Show();
}

View File

@ -8,7 +8,7 @@
#include <Application.h>
#include "MainWindow.h"
class MainWindow;
class TheApp : public BApplication {
public:
@ -21,7 +21,6 @@ public:
private:
MainWindow* fMainWin;
};
#endif // _THE_APP_H

View File

@ -6,6 +6,7 @@
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
*/
#include <Alert.h>
#include <Button.h>
#include <ControlLook.h>
#include <GroupLayout.h>
@ -19,30 +20,29 @@
#include "AccountView.h"
#include "ProtocolSettings.h"
const uint32 kCancel = 'CANC';
const uint32 kOK = 'SAVE';
const uint32 kCancel = 'canc';
const uint32 kOK = 'save';
AccountDialog::AccountDialog(const char* title, CayaProtocol* cayap,
AccountDialog::AccountDialog(const char* title, ProtocolSettings* settings,
const char* account)
: BWindow(BRect(0, 0, 1, 1), title, B_MODAL_WINDOW, B_NOT_RESIZABLE |
B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE)
B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
fSettings(settings),
fAccount(account),
fTarget(NULL)
{
fSettings = new ProtocolSettings(cayap);
fAccountName = new BTextControl("accountName", "Account name:", NULL, NULL);
fAccountName->SetExplicitMinSize(BSize(300, B_SIZE_UNSET));
fAccountName->SetFont(be_bold_font);
if (account) {
fAccountName->SetText(account);
fAccountName->SetEnabled(false);
} else
fAccountName->MakeFocus(true);
fAccountName->SetText(fAccount.String());
Divider* divider = new Divider("divider", B_WILL_DRAW);
fTop = new AccountView("top");
if (account)
fSettings->Load(account, fTop);
if (fAccount.Length() > 0)
fSettings->Load(fAccount.String(), fTop);
else
fSettings->LoadTemplate(fTop);
@ -65,24 +65,69 @@ AccountDialog::AccountDialog(const char* title, CayaProtocol* cayap,
.SetInsets(spacing, spacing, spacing, 0)
);
fAccountName->MakeFocus(true);
CenterOnScreen();
}
void
AccountDialog::SetTarget(BHandler* target)
{
fTarget = target;
}
void
AccountDialog::MessageReceived(BMessage* msg)
{
switch (msg->what) {
case kOK:
if (fSettings->Save(fAccountName->Text(), fTop) == B_OK)
case kOK: {
// Are we renaming settings?
bool renaming = ((fAccount.Length() > 0)
&& (fAccount != fAccountName->Text()));
// Rename account settings
if (renaming) {
if (fSettings->Rename(fAccount.String(), fAccountName->Text()) != B_OK) {
BString text("An error is occurred renaming the account ");
text << fAccount << " to " << fAccountName->Text() << "!";
BAlert* alert = new BAlert("", text.String(), "OK", NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->Go();
return;
}
}
// Save account settings
if (fSettings->Save(fAccountName->Text(), fTop) == B_OK) {
if (fTarget) {
BMessage* saveMsg = new BMessage(renaming
? kAccountRenamed : kAccountSaved);
saveMsg->AddPointer("settings", fSettings);
if (renaming) {
saveMsg->AddString("from", fAccount.String());
saveMsg->AddString("to", fAccountName->Text());
} else
saveMsg->AddString("account", fAccountName->Text());
BMessenger(fTarget).SendMessage(saveMsg);
}
Close();
// TODO: Error!
} else {
BAlert* alert = new BAlert("", "An error is occurred saving the settings.\n"
"Check if your disk has enough space.", "OK", NULL, NULL, B_WIDTH_AS_USUAL,
B_STOP_ALERT);
alert->Go();
Close();
}
break;
}
case kCancel:
Close();
break;
case kChanged:
msg->PrintToStream();
break;
default:
BWindow::MessageReceived(msg);

View File

@ -5,25 +5,32 @@
#ifndef _ACCOUNT_DIALOG_H
#define _ACCOUNT_DIALOG_H
#include <String.h>
#include <Window.h>
class BTextControl;
class AccountView;
class CayaProtocol;
class ProtocolSettings;
const uint32 kAccountSaved = 'acsd';
const uint32 kAccountRenamed = 'acrd';
class AccountDialog : public BWindow {
public:
AccountDialog(const char* title, CayaProtocol* cayap,
const char* account = NULL);
AccountDialog(const char* title, ProtocolSettings* settings,
const char* account = NULL);
void SetTarget(BHandler* target);
virtual void MessageReceived(BMessage* msg);
private:
ProtocolSettings* fSettings;
BString fAccount;
AccountView* fTop;
BTextControl* fAccountName;
BHandler* fTarget;
};
#endif // _ACCOUNT_DIALOG_H

View File

@ -9,23 +9,20 @@
#include <View.h>
#include "AccountListItem.h"
#include "CayaProtocol.h"
#include "ProtocolSettings.h"
AccountListItem::AccountListItem(CayaProtocol* cayap, const char* account)
AccountListItem::AccountListItem(ProtocolSettings* settings, const char* account)
: BStringItem(account),
fProtocol(cayap),
fSettings(settings),
fAccount(account),
fBaselineOffset(0)
{
fSettings = new ProtocolSettings(cayap);
}
AccountListItem::~AccountListItem()
{
delete fSettings;
}
@ -36,13 +33,6 @@ AccountListItem::Settings() const
}
CayaProtocol*
AccountListItem::Protocol() const
{
return fProtocol;
}
const char*
AccountListItem::Account() const
{
@ -50,6 +40,14 @@ AccountListItem::Account() const
}
void
AccountListItem::SetAccount(const char* name)
{
fAccount = name;
SetText(fAccount);
}
void
AccountListItem::DrawItem(BView* owner, BRect frame, bool complete)
{

View File

@ -8,18 +8,18 @@
#include <String.h>
#include <StringItem.h>
class CayaProtocol;
class ProtocolSettings;
class AccountListItem : public BStringItem {
public:
AccountListItem(CayaProtocol* cayap,
AccountListItem(ProtocolSettings* settings,
const char* account);
virtual ~AccountListItem();
ProtocolSettings* Settings() const;
CayaProtocol* Protocol() const;
const char* Account() const;
void SetAccount(const char* name);
void DrawItem(BView* owner, BRect frame,
bool complete = false);
@ -27,9 +27,8 @@ public:
void Update(BView* owner, const BFont* font);
private:
CayaProtocol* fProtocol;
BString fAccount;
ProtocolSettings* fSettings;
BString fAccount;
float fBaselineOffset;
};

View File

@ -23,11 +23,23 @@
#include "PreferencesAccounts.h"
#include "ProtocolManager.h"
#include "ProtocolSettings.h"
#include "MainWindow.h"
#include "TheApp.h"
const uint32 kAddAccount = 'ADAC';
const uint32 kEditAccount = 'EDAC';
const uint32 kDelAccount = 'DLAC';
const uint32 kSelect = 'SELT';
const uint32 kAddAccount = 'adac';
const uint32 kEditAccount = 'edac';
const uint32 kDelAccount = 'dlac';
const uint32 kSelect = 'selt';
static int
compare_by_name(const void* _item1, const void* _item2)
{
AccountListItem* item1 = *(AccountListItem**)_item1;
AccountListItem* item2 = *(AccountListItem**)_item2;
return strcasecmp(item1->Account(), item2->Account());
}
PreferencesAccounts::PreferencesAccounts()
@ -40,27 +52,23 @@ PreferencesAccounts::PreferencesAccounts()
BScrollView* scrollView = new BScrollView("scrollView", fListView,
B_WILL_DRAW, false, true);
BList* protocols = ProtocolManager::Get()->GetProtocols();
ProtocolAddOns addOns = ProtocolManager::Get()->Protocols();
fProtosMenu = new BPopUpMenu(NULL, true);
for (int32 i = 0; i < protocols->CountItems(); i++) {
CayaProtocol* cayap
= reinterpret_cast<CayaProtocol*>(protocols->ItemAtFast(i));
ProtocolSettings* settings = new ProtocolSettings(cayap);
for (uint32 i = 0; i < addOns.CountItems(); i++) {
CayaProtocolAddOn* addOn = addOns.ItemAt(i);
ProtocolSettings* settings = new ProtocolSettings(addOn);
// Add accounts to list view
_LoadListView(settings);
// Add menu items
BMessage* msg = new BMessage(kAddAccount);
msg->AddPointer("protocol", cayap);
msg->AddPointer("settings", settings);
BitmapMenuItem* item = new BitmapMenuItem(
cayap->GetFriendlySignature(), msg,
ProtocolManager::Get()->GetProtocolIcon(cayap->GetSignature()));
addOn->FriendlySignature(), msg, addOn->Icon());
fProtosMenu->AddItem(item);
delete settings;
}
ToolButton* proto = new ToolButton("+", NULL);
@ -110,15 +118,16 @@ PreferencesAccounts::MessageReceived(BMessage* msg)
}
break;
case kAddAccount: {
void *protocol = NULL;
if (msg->FindPointer("protocol", &protocol) == B_OK) {
CayaProtocol* cayap = (CayaProtocol*) protocol;
BLooper* looper = new BLooper();
looper->AddHandler(this);
AccountDialog* dialog = new AccountDialog("Add account", cayap);
dialog->Show();
void *pointer = NULL;
if (msg->FindPointer("settings", &pointer) == B_OK) {
ProtocolSettings* settings
= reinterpret_cast<ProtocolSettings*>(pointer);
if (settings) {
AccountDialog* dialog = new AccountDialog("Add account",
settings);
dialog->SetTarget(this);
dialog->Show();
}
}
break;
}
@ -131,13 +140,9 @@ PreferencesAccounts::MessageReceived(BMessage* msg)
AccountListItem* item
= dynamic_cast<AccountListItem*>(fListView->ItemAt(selected));
CayaProtocol* cayap = item->Protocol();
const char* account = item->Account();
BLooper* looper = new BLooper();
looper->AddHandler(this);
AccountDialog* dialog = new AccountDialog("Edit account", cayap, account);
AccountDialog* dialog = new AccountDialog("Edit account",
item->Settings(), item->Account());
dialog->SetTarget(this);
dialog->Show();
}
break;
@ -159,6 +164,57 @@ PreferencesAccounts::MessageReceived(BMessage* msg)
}
break;
}
case kAccountSaved:
case kAccountRenamed: {
void* pointer = NULL;
BString account;
BString account2;
if (msg->FindPointer("settings", &pointer) != B_OK)
return;
if (msg->what == kAccountSaved) {
if (msg->FindString("account", &account) != B_OK)
return;
} else {
if (msg->FindString("from", &account) != B_OK)
return;
if (msg->FindString("to", &account2) != B_OK)
return;
}
ProtocolSettings* settings
= reinterpret_cast<ProtocolSettings*>(pointer);
if (!settings)
return;
if (msg->what == kAccountSaved) {
// Add list item
AccountListItem* listItem
= new AccountListItem(settings, account.String());
fListView->AddItem(listItem);
// Add protocol/account instance
TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
ProtocolManager::Get()->AddAccount(settings->AddOn(),
account.String(), theApp->GetMainWindow());
} else {
// Rename list item
for (int32 i = 0; i < fListView->CountItems(); i++) {
AccountListItem* listItem
= dynamic_cast<AccountListItem*>(fListView->ItemAt(i));
if (!listItem)
continue;
if (account == listItem->Account()) {
listItem->SetAccount(account2.String());
break;
}
}
}
fListView->SortItems(compare_by_name);
break;
}
default:
BView::MessageReceived(msg);
}
@ -176,8 +232,8 @@ PreferencesAccounts::_LoadListView(ProtocolSettings* settings)
// Add accounts to list view
for (uint32 i = 0; i < accounts.CountItems(); i++) {
BString account = accounts.ItemAt(i);
AccountListItem* listItem = new AccountListItem(
settings->Protocol(), account.String());
AccountListItem* listItem
= new AccountListItem(settings, account.String());
fListView->AddItem(listItem);
}
}

View File

@ -72,8 +72,9 @@ RosterListView::MessageReceived(BMessage* msg)
{
switch (msg->what) {
case kGetInfo:
msg->PrintToStream();
break;
default:
BListView::MessageReceived(msg);
}
}

View File

@ -24,7 +24,7 @@
#include "StatusMenuItem.h"
#include "StatusView.h"
const int32 kSetNickname = 'NICH';
const int32 kSetNickname = 'stnk';
StatusView::StatusView(const char* name)

1
configure vendored
View File

@ -137,6 +137,7 @@ BEOS_PREFERENCES_DIRECTORY = $(finddir B_BEOS_PREFERENCES_DIRECTORY) ;
PREFERENCES_DIRECTORY = $(finddir B_PREFERENCES_DIRECTORY) ;
USER_PREFERENCES_DIRECTORY = $(finddir B_USER_CONFIG_DIRECTORY)/be/Preferences ;
APPS_DIRECTORY = $(finddir B_APPS_DIRECTORY) ;
CAYA_DIRECTORY = $(finddir B_APPS_DIRECTORY)/Caya ;
DEFINES += ${defines} ;
EOF

View File

@ -439,7 +439,7 @@ JabberHandler::BeginSession()
fSocket = fPlug->StartConnection(fHost, fPort, this);
if (fSocket >= 0) {
xml << "<stream:stream to=\'" << fHost
xml << "<stream:stream version='1.0' to=\'" << fHost
<< "\' xmlns='jabber:client' "
<< "xmlns:stream='http://etherx.jabber.org/streams'>\n";
Send(xml);

View File

@ -88,7 +88,6 @@ VCardManager::RefinePresence(JabberPresence* presence)
logmsg(" not found in cache.. adding\n");
jid.AddString("photo-sha1", presence->GetPhotoSHA1().String());
fCache.AddMessage(presence->GetJid().String(), &jid);
jid.PrintToStream();
SaveCache();
logmsg("...asking for downloading the image..\n");
fJabberHandler->RequestVCard(presence->GetJid());

View File

@ -7,25 +7,24 @@
#include <map>
#include <List.h>
#include <SupportDefs.h>
#include <libsupport/List.h>
template<class KEY, class TYPE>
class KeyMap {
public:
uint32 CountItems();
uint32 CountItems();
void AddItem(KEY k, TYPE t);
void AddItem(KEY k, TYPE t);
TYPE ValueFor(KEY, bool* found = NULL);
TYPE ValueFor(KEY, bool* found = NULL);
void RemoveItemAt(int32 position);
void RemoveItemFor(KEY);
void RemoveItemAt(int32 position);
void RemoveItemFor(KEY);
TYPE ValueAt(int32 position);
KEY KeyAt(int32 position);
TYPE ValueAt(int32 position);
KEY KeyAt(int32 position);
BList* Items();
List<TYPE> Values();
private:
std::map<KEY,TYPE> fMap;
@ -104,12 +103,12 @@ KEY KeyMap<KEY, TYPE>::KeyAt(int32 position)
template<class KEY, class TYPE>
BList* KeyMap<KEY, TYPE>::Items()
List<TYPE> KeyMap<KEY, TYPE>::Values()
{
BList* list = new BList();
List<TYPE> list;
for (fIter i = fMap.begin(); i != fMap.end(); ++i)
list->AddItem(i->second);
list.AddItem(i->second);
return list;
}

View File

@ -1,5 +1,6 @@
SubDir TOP protocols ;
# Include all the components.
SubInclude TOP protocols gtalk ;
SubInclude TOP protocols aim ;
SubInclude TOP protocols gtalk ;
SubInclude TOP protocols facebook ;

View File

@ -11,7 +11,8 @@
#include "AIM.h"
const char* kProtocolName = "aim";
const char* kProtocolSignature = "aim";
const char* kProtocolName = "AOL Instant Messenger";
CayaProtocolMessengerInterface* gServerMsgr;
@ -105,7 +106,7 @@ AIMProtocol::Process(BMessage* msg)
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_SET);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddInt32("status", status);
gServerMsgr->SendMessage(&msg);
break;
@ -121,7 +122,7 @@ AIMProtocol::Process(BMessage* msg)
// XXX send a message to let caya know we did it
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_MESSAGE_SENT);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", buddy);
msg.AddString("message", sms);
@ -182,27 +183,27 @@ AIMProtocol::UnsupportedOperation()
const char*
AIMProtocol::GetSignature()
AIMProtocol::Signature() const
{
return kProtocolSignature;
}
const char*
AIMProtocol::FriendlySignature() const
{
return kProtocolName;
}
const char*
AIMProtocol::GetFriendlySignature()
{
return "AOL Instant Messenger";
}
status_t
AIMProtocol::UpdateSettings(BMessage& msg)
AIMProtocol::UpdateSettings(BMessage* msg)
{
const char* username = NULL;
const char* password = NULL;
msg.FindString("username", &username);
msg.FindString("password", &password);
msg->FindString("username", &username);
msg->FindString("password", &password);
//msg->FindString("server", &server);
//msg->FindInt32("port", &server);
@ -228,6 +229,13 @@ AIMProtocol::GetEncoding()
}
CayaProtocolMessengerInterface*
AIMProtocol::MessengerInterface() const
{
return gServerMsgr;
}
status_t
AIMProtocol::A_LogOn()
{
@ -282,7 +290,7 @@ AIMProtocol::GotMessage(void* imcomm, char* who, int auto, char* recvmsg)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_MESSAGE_RECEIVED);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", who);
msg.AddString("message", strip_html(recvmsg));
@ -295,7 +303,7 @@ AIMProtocol::BuddyOnline(void* imcomm, char* who)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_CHANGED);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", who);
msg.AddInt32("status", CAYA_ONLINE);
@ -308,7 +316,7 @@ AIMProtocol::BuddyOffline(void* imcomm, char* who)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_CHANGED);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", who);
msg.AddInt32("status", CAYA_OFFLINE);
@ -328,7 +336,7 @@ AIMProtocol::BuddyBack(void* imcomm, char* who)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_CHANGED);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", who);
msg.AddInt32("status", CAYA_ONLINE);
@ -341,7 +349,7 @@ AIMProtocol::BuddyAwayMsg(void* imcomm, char* who, char* awaymsg)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_CHANGED);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", who);
msg.AddInt32("status", CAYA_EXTENDED_AWAY);
msg.AddString("message", strip_html(awaymsg));
@ -355,7 +363,7 @@ AIMProtocol::BuddyIdle(void* imcomm, char* who, long idletime)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_CHANGED);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", who);
msg.AddInt32("status", CAYA_ONLINE);

View File

@ -24,11 +24,15 @@ public:
virtual status_t Shutdown();
virtual status_t Process(BMessage*);
virtual const char* GetSignature();
virtual const char* GetFriendlySignature();
virtual status_t UpdateSettings(BMessage&);
virtual const char* Signature() const;
virtual const char* FriendlySignature() const;
virtual status_t UpdateSettings(BMessage*);
virtual uint32 GetEncoding();
virtual CayaProtocolMessengerInterface*
MessengerInterface() const;
static int32 WaitForData(void*);
static void GotMessage(void*, char*, int, char*);
@ -55,4 +59,7 @@ private:
void* fIMCommHandle;
};
extern const char* kProtocolSignature;
extern const char* kProtocolName;
#endif // _AIM_H

View File

@ -7,17 +7,13 @@ SubDirSysHdrs [ FDirName $(TOP) libs libimcomm ] ;
SEARCH_SOURCE += [ FDirName $(TOP) protocols aim ] ;
local sources =
AddOn aim :
AIM.cpp
main.cpp
;
AddOn aim :
$(sources)
: libimcomm.a be network $(TARGET_LIBSTDC++)
: aim.rdef
: aim.rdef settings_template.rdef
;
Depends aim : libimcomm.a ;
InstallBin $(APPS_DIRECTORY)/caya/protocols : aim ;
InstallBin $(CAYA_DIRECTORY)/protocols : aim ;

View File

@ -5,9 +5,26 @@
#include "AIM.h"
extern "C" __declspec(dllexport) CayaProtocol *main_protocol();
extern "C" __declspec(dllexport) CayaProtocol* protocol();
extern "C" __declspec(dllexport) const char* signature();
extern "C" __declspec(dllexport) const char* friendly_signature();
CayaProtocol *main_protocol()
CayaProtocol*
protocol()
{
return (CayaProtocol*)new AIMProtocol();
}
const char*
signature()
{
return kProtocolSignature;
}
const char*
friendly_signature()
{
return kProtocolName;
}

View File

@ -0,0 +1,13 @@
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
}
};

View File

@ -0,0 +1,852 @@
#include <stdio.h>
#include <string>
#include <Entry.h>
#include <libjabber/JabberSocketPlug.h>
#include <libjabber/States.h>
#include "Facebook.h"
const char* kProtocolSignature = "facebook";
const char* kProtocolName = "Facebook";
int64 idsms = 0;
Facebook::Facebook()
: JabberHandler("jabberHandler", fPlug = new JabberSocketPlug()),
fUsername(""),
fServer("chat.facebook.com"),
fPassword("")
{
}
Facebook::~Facebook()
{
Shutdown();
}
status_t
Facebook::Init(CayaProtocolMessengerInterface* msgr)
{
fServerMsgr = msgr;
fRostered = false;
fAgent = false;
fFullLogged = false;
fPerc = 0.0;
fLaterBuddyList = new StrList();
return B_OK;
}
status_t
Facebook::Shutdown()
{
LogOff();
fLaterBuddyList->clear();
delete fLaterBuddyList;
// thread_id plug = fPlug->Thread();
// BMessenger(fPlug).SendMessage(B_QUIT_REQUESTED);
fPlug = NULL;
int32 res = 0;
// wait_for_thread(plug, &res);
return B_OK;
}
status_t
Facebook::Process(BMessage* msg)
{
switch (msg->what) {
case IM_MESSAGE:
{
int32 im_what = 0;
msg->FindInt32("im_what", &im_what);
switch (im_what) {
case IM_SET_NICKNAME:
{
BString nick;
if (msg->FindString("nick", &nick) == B_OK)
SetOwnNickname(nick);
break;
}
case IM_SET_STATUS:
{
int32 status = msg->FindInt32("status");
BString status_msg("");
msg->FindString("message", &status_msg);
switch (status) {
case CAYA_ONLINE:
if (!IsAuthorized()) {
if (fServer == "")
Error("Empty Server!", NULL);
if (fUsername == "")
Error("Empty Username!", NULL);
if (fPassword == "")
Error("Empty Password!",NULL);
Progress("Facebook Login", "Facebook: Connecting...", 0.0f);
SetStatus(S_ONLINE, "");
RequestVCard(GetJid()); //by default we ask for our own vCard.
} else {
SetStatus(S_ONLINE, "");
SetAway(false);
}
break;
case CAYA_AWAY:
if (IsAuthorized()) {
SetStatus(S_AWAY, status_msg);
SetAway(true);
}
break;
case CAYA_EXTENDED_AWAY:
if (IsAuthorized()) {
SetStatus(S_XA, status_msg);
SetAway(true);
}
break;
case CAYA_DO_NOT_DISTURB:
if (IsAuthorized()) {
SetStatus(S_DND, status_msg);
}
break;
case CAYA_OFFLINE:
SetStatus(S_OFFLINE, "");
break;
default:
Error("Invalid", NULL);
break;
}
break;
}
case IM_SEND_MESSAGE:
{
const char* buddy = msg->FindString("id");
const char* sms = msg->FindString("message");
JabberMessage jm;
jm.SetTo(buddy);
jm.SetFrom(GetJid());
jm.SetBody(sms);
TimeStamp(jm);
// Not the right place.. see Jabber::Message
JabberContact* contact = getContact(buddy);
//tmp: new mess id!
BString messid("caya");
messid << idsms;
idsms++;
if (contact)
jm.SetID(messid);
SendMessage(jm);
MessageSent(buddy,sms);
break;
}
case IM_REGISTER_CONTACTS:
{
type_code garbage;
int32 count = 0;
msg->GetInfo("id", &garbage, &count);
if (count > 0) {
for (int i = 0; msg->FindString("id", i); i++) {
const char* id = msg->FindString("id", i);
JabberContact* contact = getContact(id);
if (contact)
BuddyStatusChanged(contact);
else {
// Are we on-line?
// send auth req?
if (fFullLogged) {
AddContact(id, id, "");
BuddyStatusChanged(id, CAYA_OFFLINE);
} else {
// we add to a temp list.
// when logged in we will register the new buddy...
fLaterBuddyList->push_back(BString(id));
}
}
}
} else
return B_ERROR;
break;
}
case IM_UNREGISTER_CONTACTS:
{
const char* buddy = NULL;
for (int i = 0; msg->FindString("id", i, &buddy) == B_OK; i++) {
//LOG(kProtocolSignature, liDebug, "Unregister Contact: '%s'", buddy);
if (!fFullLogged)
BuddyStatusChanged(buddy, CAYA_OFFLINE);
else {
//LOG(kProtocolSignature, liDebug, "Unregister Contact DOING IT");
JabberContact* contact = getContact(buddy);
if (contact)
RemoveContact(contact);
}
}
break;
}
case IM_USER_STARTED_TYPING:
{
const char* id = NULL;
if (msg->FindString("id", &id) == B_OK) {
JabberContact* contact=getContact(id);
if (contact)
StartComposingMessage(contact);
}
break;
}
case IM_USER_STOPPED_TYPING:
{
const char* id = NULL;
if (msg->FindString("id", &id) == B_OK) {
JabberContact* contact = getContact(id);
if (contact && (contact->GetLastMessageID().ICompare("") != 0)) {
StopComposingMessage(contact);
contact->SetLastMessageID("");
}
}
break;
}
case IM_GET_CONTACT_INFO:
SendContactInfo(msg->FindString("id"));
break;
case IM_SEND_AUTH_ACK:
{
if (!IsAuthorized())
return B_ERROR;
const char* id = msg->FindString("id");
int32 button = msg->FindInt32("which");
if (button == 0) {
// Authorization granted
AcceptSubscription(id);
BMessage im_msg(IM_MESSAGE);
im_msg.AddInt32("im_what", IM_CONTACT_AUTHORIZED);
im_msg.AddString("protocol", kProtocolSignature);
im_msg.AddString("id", id);
im_msg.AddString("message", "");
fServerMsgr->SendMessage(&im_msg);
// Now we want to see you! ;)
AddContact(id, id, "");
} else {
// Authorization rejected
Error("Authorization rejected!",id);
}
break;
}
case IM_SPECIAL_TO_PROTOCOL:
Send(msg->FindString("direct_data"));
break;
default:
// We don't handle this im_what code
//LOG(kProtocolSignature, liDebug, "Got unhandled message: %ld", im_what);
msg->PrintToStream();
return B_ERROR;
}
break;
}
default:
// We don't handle this what code
return B_ERROR;
}
return B_OK;
}
const char*
Facebook::Signature() const
{
return kProtocolSignature;
}
const char*
Facebook::FriendlySignature() const
{
return kProtocolName;
}
status_t
Facebook::UpdateSettings(BMessage* msg)
{
const char* username = NULL;
const char* password = NULL;
const char* res = NULL;
msg->FindString("username", &username);
msg->FindString("password", &password);
msg->FindString("resource", &res);
if ((username == NULL) || (password == NULL)) {
//LOG( kProtocolSignature, liHigh, "Invalid settings!");
printf("Invalid settings");
return B_ERROR;
}
fUsername = username;
int32 atpos=fUsername.FindLast("@");
if (atpos> 0) {
BString server;
fUsername.CopyInto(server,atpos + 1,fUsername.Length()-atpos);
fUsername.Remove(atpos,fUsername.Length()-atpos);
fServer = server;
} else
fServer.SetTo("chat.facebook.com");
fPassword = password;
SetUsername(fUsername);
SetHost(fServer);
SetPassword(fPassword);
if (strlen(res)==0)
SetResource("caya");
else
SetResource(res);
SetPriority(5);
SetPort(5222);
return B_OK;
}
uint32
Facebook::GetEncoding()
{
return 0xffff; // No conversion, Facebook handles UTF-8 ???
}
// JabberManager stuff
void
Facebook::Error(const char* message, const char* who)
{
//LOG("Facebook", liDebug, "Facebook::Error(%s,%s)", message, who);
BMessage msg(IM_ERROR);
msg.AddString("protocol", kProtocolSignature);
if (who)
msg.AddString("id", who);
msg.AddString("error", message);
fServerMsgr->SendMessage( &msg );
}
void
Facebook::GotMessage(const char* from, const char* message)
{
//LOG("Facebook", liDebug, "Facebook::GotMessage()");
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_MESSAGE_RECEIVED);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", from);
msg.AddString("message", message);
fServerMsgr->SendMessage( &msg );
}
void
Facebook::MessageSent(const char* to, const char* message)
{
//LOG("Facebook", liDebug, "Facebook::GotMessage()");
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_MESSAGE_SENT);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", to);
msg.AddString("message", message);
fServerMsgr->SendMessage( &msg );
}
void
Facebook::LoggedIn()
{
Progress("Facebook Login", "Facebook: Logged in!", 1.00);
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_SET);
msg.AddString("protocol", kProtocolSignature);
msg.AddInt32("status", CAYA_ONLINE);
fServerMsgr->SendMessage(&msg);
fFullLogged = true;
while (fLaterBuddyList->size() != 0) {
BString id = *(fLaterBuddyList->begin());
fLaterBuddyList->pop_front(); // removes first item
JabberContact* contact=getContact(id.String());
if (!contact) {
AddContact(id.String(),id.String(),"");
BuddyStatusChanged(id.String(), CAYA_OFFLINE);
}
}
}
void
Facebook::SetAway(bool away)
{
//LOG("Facebook", liDebug, "Facebook::SetAway()");
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_SET);
msg.AddString("protocol", kProtocolSignature);
if ( away )
msg.AddInt32("status", CAYA_AWAY);
else
msg.AddInt32("status", CAYA_ONLINE);
fServerMsgr->SendMessage( &msg );
}
void
Facebook::LoggedOut()
{
//LOG("Facebook", liDebug, "Facebook::LoggedOut()");
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_SET);
msg.AddString("protocol", kProtocolSignature);
msg.AddInt32("status", CAYA_OFFLINE);
fServerMsgr->SendMessage(&msg);
fFullLogged = false;
fRostered = false;
fAgent = false;
fPerc = 0.0;
}
void
Facebook::BuddyStatusChanged(JabberContact* who)
{
BuddyStatusChanged(who->GetPresence());
}
void
Facebook::BuddyStatusChanged(JabberPresence* jp)
{
//LOG("Facebook", liDebug, "Facebook::BuddyStatusChanged(%s)",jp->GetJid().String());
//avoid a receiving self status changes or empty status:
if (jp->GetJid() == "" || jp->GetJid().ICompare(GetJid()) == 0)
return;
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_CHANGED);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", jp->GetJid());
msg.AddString("resource", jp->GetResource());
AddStatusString(jp, &msg);
fServerMsgr->SendMessage(&msg);
}
void
Facebook::AddStatusString(JabberPresence* jp, BMessage* msg)
{
int32 show = jp->GetShow();
switch (show) {
case S_XA:
msg->AddInt32("status", CAYA_EXTENDED_AWAY);
break;
case S_AWAY:
msg->AddInt32("status", CAYA_AWAY);
break;
case S_ONLINE:
msg->AddInt32("status", CAYA_ONLINE);
break;
case S_DND:
msg->AddInt32("status", CAYA_DO_NOT_DISTURB);
break;
case S_CHAT:
msg->AddInt32("status", CAYA_ONLINE);
break;
case S_SEND:
msg->AddInt32("status", CAYA_ONLINE);
break;
default:
msg->AddInt32("status", CAYA_OFFLINE);
break;
}
if (jp->GetType().ICompare("unavailable") == 0)
msg->AddInt32("status", CAYA_OFFLINE);
msg->AddString("message", jp->GetStatus());
}
void
Facebook::BuddyStatusChanged(const char* who, CayaStatus status)
{
//LOG("Facebook", liDebug, "Facebook::BuddyStatusChanged(%s,%s)",who,status);
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_CHANGED);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", who);
msg.AddInt32("status", status);
fServerMsgr->SendMessage( &msg );
}
void
Facebook::Progress(const char* id, const char* message, float progress)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_PROGRESS );
msg.AddString("protocol", kProtocolSignature);
msg.AddString("progressID", id);
msg.AddString("message", message);
msg.AddFloat("progress", progress);
msg.AddInt32("state", 11); //IM_impsConnecting );
fServerMsgr->SendMessage(&msg);
}
JabberContact*
Facebook::getContact(const char* id)
{
RosterList *rl = getRosterList();
JabberContact* contact = NULL;
//LOG(kProtocolSignature, liDebug, "getContact %s", id);
for(int32 i = 0; i < rl->CountItems(); i++) {
contact = reinterpret_cast<JabberContact*>(getRosterList()->ItemAt(i));
//LOG(kProtocolSignature, liDebug, "getContact [%3d] GetJID %s", i,contact->GetJid().String());
if (contact->GetJid().ICompare(id) == 0) {
//LOG(kProtocolSignature, liDebug, "getContact found!");
return contact;
}
}
return NULL;
}
void
Facebook::SendContactInfo(const JabberContact* jid)
{
int32 what = IM_CONTACT_INFO;
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", what);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", jid->GetJid());
msg.AddString("nick", jid->GetName());
// vCard information
JabberVCard* vCard = jid->GetVCard();
if (vCard) {
msg.AddString("full name", vCard->GetFullName());
msg.AddString("first name", vCard->GetGivenName());
msg.AddString("middle name", vCard->GetMiddleName());
msg.AddString("last name", vCard->GetFamilyName());
msg.AddString("email", vCard->GetEmail());
msg.AddString("birthday", vCard->GetBirthday());
msg.AddString("url", vCard->GetURL());
entry_ref ref;
if (get_ref_for_path(vCard->GetCachedPhotoFile().String(), &ref) == B_OK)
msg.AddRef("ref", &ref);
}
// Send contact information
fServerMsgr->SendMessage(&msg);
}
void
Facebook::SendContactInfo(const char* id)
{
JabberContact* jid = getContact(id);
if (!jid)
return;
SendContactInfo(jid);
}
void
Facebook::SendBuddyIcon(const char* id)
{
JabberContact* jid = getContact(id);
if (!jid)
return;
// vCard information
JabberVCard* vCard = jid->GetVCard();
if (vCard) {
BString data = vCard->GetPhotoContent();
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_SET_AVATAR);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", id);
msg.AddData("icondata", B_RAW_TYPE, data.String(), data.Length());
fServerMsgr->SendMessage(&msg);
}
}
// Callbacks
void
Facebook::Authorized()
{
SetAway(false);
fPerc +=0.3333f;
Progress("Facebook Login", "Facebook: Authorized", fPerc);
//LOG(kProtocolSignature, liDebug, "Facebook:Login %f - Authorized",fPerc) ;
CheckLoginStatus();
JabberHandler::Authorized();
}
void
Facebook::Message(JabberMessage* message)
{
// We have something to tell
if (message->GetBody() != "")
GotMessage(message->GetFrom().String(), message->GetBody().String());
// Not a nice situation..
if(message->GetError() != "") {
Error(message->GetError().String(),message->GetFrom().String());
return;
}
//LOG(kProtocolSignature, liHigh, "GETX: '%s'",message->GetX().String()) ;
if (message->GetX().ICompare("composing") == 0) {
// Someone send a composing event...
if (message->GetBody() == "") {
//LOG(kProtocolSignature, liHigh,"CONTACT_STARTED_TYPING");
BMessage im_msg(IM_MESSAGE);
im_msg.AddInt32("im_what", IM_CONTACT_STARTED_TYPING);
im_msg.AddString("protocol", kProtocolSignature);
im_msg.AddString("id", message->GetFrom());
fServerMsgr->SendMessage(&im_msg);
} else {
// where we put the last messge id? on the contact (is it the right place?)
// maybe we should make an hash table? a BMesage..
JabberContact* contact = getContact(message->GetFrom().String());
if(contact)
contact->SetLastMessageID(message->GetID());
}
} else if (message->GetX().ICompare("jabber:x:event") == 0) {
//not define event this maybe due to:
// unkown event.
// no event (means stop all)
//LOG(kProtocolSignature, liHigh,"CONTACT_STOPPED_TYPING");
BMessage im_msg(IM_MESSAGE);
im_msg.AddInt32("im_what", IM_CONTACT_STOPPED_TYPING);
im_msg.AddString("protocol", kProtocolSignature);
im_msg.AddString("id", message->GetFrom());
fServerMsgr->SendMessage(&im_msg);
}
}
void
Facebook::Presence(JabberPresence* presence)
{
BuddyStatusChanged(presence);
}
void
Facebook::Roster(RosterList* roster)
{
// Fix me! (Roster message can arrive at different times)
BMessage serverBased(IM_SERVER_BASED_CONTACT_LIST);
serverBased.AddString("protocol", kProtocolSignature);
JabberContact* contact;
int size = roster->CountItems();
for(int32 i = 0; i < size; i++) {
contact = reinterpret_cast<JabberContact*>(roster->ItemAt(i));
serverBased.AddString("id", contact->GetJid());
}
fServerMsgr->SendMessage(&serverBased);
for (int32 i=0; i < size; i++) {
contact = reinterpret_cast<JabberContact*>(roster->ItemAt(i));
SendContactInfo(contact);
}
// Here the case when more than one roster message has arrived!
if(!fRostered) {
fPerc += 0.3333f;
fRostered = true;
Progress("Facebook Login", "Facebook: Roster", fPerc);
}
//LOG(kProtocolSignature, liDebug, "Facebook:Login %f - Rostered",fPerc) ;
CheckLoginStatus();
}
void
Facebook::Agents(AgentList* agents)
{
fPerc +=0.3333f;
fAgent = true;
Progress("Facebook Login", "Facebook: Agents", fPerc);
//LOG(kProtocolSignature, liDebug, "Facebook:Login %f - Agents",fPerc) ;
CheckLoginStatus();
}
void
Facebook::Disconnected(const BString& reason)
{
LoggedOut();
if (reason == "")
return;
Error(reason.String(),NULL);
}
void
Facebook::SubscriptionRequest(JabberPresence* presence)
{
BMessage im_msg(IM_MESSAGE);
im_msg.AddInt32("im_what", IM_AUTH_REQUEST);
im_msg.AddString("protocol", kProtocolSignature);
im_msg.AddString("id", presence->GetJid());
im_msg.AddString("message", presence->GetStatus());
fServerMsgr->SendMessage(&im_msg);
}
void
Facebook::Unsubscribe(JabberPresence* presence)
{
// What should we do when a people unsubscrive from us?
//debugger("Unsubscribe");
//LOG("Facebook", liDebug, "Facebook::Unsubscribe()");
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_CHANGED);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", presence->GetJid());
msg.AddInt32("status", CAYA_OFFLINE);
fServerMsgr->SendMessage(&msg);
}
void
Facebook::OwnContactInfo(JabberContact* contact)
{
int32 what = IM_OWN_CONTACT_INFO;
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", what);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", contact->GetJid());
msg.AddString("nick", contact->GetName());
// vCard information
JabberVCard* vCard = contact->GetVCard();
if (vCard) {
msg.AddString("full name", vCard->GetFullName());
msg.AddString("first name", vCard->GetGivenName());
msg.AddString("middle name", vCard->GetMiddleName());
msg.AddString("last name", vCard->GetFamilyName());
msg.AddString("email", vCard->GetEmail());
msg.AddString("birthday", vCard->GetBirthday());
msg.AddString("url", vCard->GetURL());
entry_ref ref;
if (get_ref_for_path(vCard->GetCachedPhotoFile().String(), &ref) == B_OK)
msg.AddRef("ref", &ref);
}
// Send information
fServerMsgr->SendMessage(&msg);
}
void
Facebook::GotBuddyPhoto(const BString& jid, const BString& imagePath)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_AVATAR_CHANGED);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", jid);
entry_ref ref;
if (get_ref_for_path(imagePath.String(), &ref) == B_OK)
msg.AddRef("ref", &ref);
fServerMsgr->SendMessage(&msg);
}
void
Facebook::Registration(JabberRegistration* registration)
{
// Just created a new account ?
// or we have ack of a registration? ack of registartion!
registration->PrintToStream();
debugger("Registration");
}
void
Facebook::CheckLoginStatus()
{
if (fRostered && fAgent && !fFullLogged)
LoggedIn();
}

View File

@ -0,0 +1,120 @@
/*
* Copyright 2004-2009, IM Kit Team. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef CAYA_Facebook_H
#define CAYA_Facebook_H
#include <list>
#include <List.h>
#include <Messenger.h>
#include <String.h>
#include <libjabber/JabberHandler.h>
#include <libjabber/JabberManager.h>
#include "CayaProtocol.h"
#include "CayaConstants.h"
//class FacebookConnection;
class JabberSocketPlug;
#define RosterList BObjectList<JabberContact>
#define AgentList BObjectList<JabberAgent>
class Facebook : public JabberManager, public JabberHandler, public CayaProtocol {
public:
Facebook();
virtual ~Facebook();
// IM::Protocol part begins here
// messenger to im_server
virtual status_t Init( CayaProtocolMessengerInterface* );
// called before unloading from memory
virtual status_t Shutdown();
// process message
virtual status_t Process( BMessage * );
// Get name of protocol
virtual const char * Signature() const;
virtual const char * FriendlySignature() const;
// settings changed
virtual status_t UpdateSettings( BMessage * );
// preferred encoding of messages
virtual uint32 GetEncoding();
// IM::Protocol part ends here
virtual CayaProtocolMessengerInterface* MessengerInterface() const { return fServerMsgr; }
// JabberManager part begins here
virtual void Error( const char * message, const char * who );
virtual void GotMessage( const char * from, const char * msg );
virtual void MessageSent( const char * to, const char * msg );
virtual void LoggedIn();
virtual void SetAway(bool);
virtual void LoggedOut();
//virtual void GotBuddyList( std::list<string> & );
virtual void BuddyStatusChanged( const char * who, CayaStatus status );
virtual void BuddyStatusChanged( JabberContact* who );
virtual void BuddyStatusChanged( JabberPresence* who );
// JabberManager part ends here
private:
JabberSocketPlug* fPlug;
CayaProtocolMessengerInterface* fServerMsgr;
BString fUsername;
BString fServer;
BString fPassword;
typedef std::list<BString> StrList; // new buddy added when off-line.
StrList* fLaterBuddyList;
//special client
//StrList fSpecialUID;
BMessage fSpecialUID;
bool fRostered;
bool fAgent;
float fPerc;
bool fFullLogged;
void Progress( const char * id, const char * message, float progress );
JabberContact* getContact(const char* id);
void SendContactInfo(const char* id);
void SendContactInfo(const JabberContact* jid);
void SendBuddyIcon(const char* id);
void AddStatusString(JabberPresence* who ,BMessage* to);
void CheckLoginStatus();
// Callbacks from JabberHandler
protected:
virtual void Authorized();
virtual void Message(JabberMessage * message);
virtual void Presence(JabberPresence * presence);
virtual void Roster(RosterList * roster);
virtual void Agents(AgentList * agents);
virtual void Disconnected(const BString & reason) ;
virtual void SubscriptionRequest(JabberPresence * presence) ;
virtual void Registration(JabberRegistration * registration) ;
virtual void Unsubscribe(JabberPresence * presence);
virtual void OwnContactInfo(JabberContact* contact);
virtual void GotBuddyPhoto(const BString & jid, const BString & imagePath);
};
extern const char* kProtocolSignature;
extern const char* kProtocolName;
#endif // CAYA_Facebook_H

View File

@ -0,0 +1,19 @@
SubDir TOP protocols facebook ;
SubDirSysHdrs [ FDirName $(TOP) ] ;
SubDirSysHdrs [ FDirName $(TOP) application ] ;
SubDirSysHdrs [ FDirName $(TOP) libs ] ;
SubDirSysHdrs [ FDirName $(TOP) libs libjabber ] ;
AddOn facebook :
main.cpp
Facebook.cpp
: be libjabber.a $(TARGET_LIBSTDC++) expat network
: facebook.rdef settings_template.rdef
;
Depends facebook : libjabber.a ;
LINKFLAGS on facebook += -L$(OPENSSL_LIBRARY_DIR) ;
InstallBin $(CAYA_DIRECTORY)/protocols : facebook ;

View File

@ -0,0 +1,34 @@
resource app_version {
major = 0,
middle = 0,
minor = 0,
variety = B_APPV_ALPHA,
internal = 0,
short_info = "Google Talk Protocol for Caya",
long_info = "©2009-2010 Andrea Anzani, 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"
};

View File

@ -0,0 +1,25 @@
#include "Facebook.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 Facebook();
}
const char*
signature()
{
return kProtocolSignature;
}
const char*
friendly_signature()
{
return kProtocolName;
}

View File

@ -8,7 +8,8 @@
#include "GoogleTalk.h"
const char* kProtocolName = "gtalk";
const char* kProtocolSignature = "gtalk";
const char* kProtocolName = "Google Talk";
int64 idsms = 0;
@ -64,8 +65,6 @@ GoogleTalk::Shutdown()
status_t
GoogleTalk::Process(BMessage* msg)
{
msg->PrintToStream();
switch (msg->what) {
case IM_MESSAGE:
{
@ -192,12 +191,12 @@ GoogleTalk::Process(BMessage* msg)
const char* buddy = NULL;
for (int i = 0; msg->FindString("id", i, &buddy) == B_OK; i++) {
//LOG(kProtocolName, liDebug, "Unregister Contact: '%s'", buddy);
//LOG(kProtocolSignature, liDebug, "Unregister Contact: '%s'", buddy);
if (!fFullLogged)
BuddyStatusChanged(buddy, CAYA_OFFLINE);
else {
//LOG(kProtocolName, liDebug, "Unregister Contact DOING IT");
//LOG(kProtocolSignature, liDebug, "Unregister Contact DOING IT");
JabberContact* contact = getContact(buddy);
if (contact)
RemoveContact(contact);
@ -245,7 +244,7 @@ GoogleTalk::Process(BMessage* msg)
AcceptSubscription(id);
BMessage im_msg(IM_MESSAGE);
im_msg.AddInt32("im_what", IM_CONTACT_AUTHORIZED);
im_msg.AddString("protocol", kProtocolName);
im_msg.AddString("protocol", kProtocolSignature);
im_msg.AddString("id", id);
im_msg.AddString("message", "");
fServerMsgr->SendMessage(&im_msg);
@ -263,7 +262,7 @@ GoogleTalk::Process(BMessage* msg)
break;
default:
// We don't handle this im_what code
//LOG(kProtocolName, liDebug, "Got unhandled message: %ld", im_what);
//LOG(kProtocolSignature, liDebug, "Got unhandled message: %ld", im_what);
msg->PrintToStream();
return B_ERROR;
}
@ -279,32 +278,32 @@ GoogleTalk::Process(BMessage* msg)
const char*
GoogleTalk::GetSignature()
GoogleTalk::Signature() const
{
return kProtocolSignature;
}
const char*
GoogleTalk::FriendlySignature() const
{
return kProtocolName;
}
const char*
GoogleTalk::GetFriendlySignature()
{
return "Google Talk";
}
status_t
GoogleTalk::UpdateSettings(BMessage& msg)
GoogleTalk::UpdateSettings(BMessage* msg)
{
const char* username = NULL;
const char* password = NULL;
const char* res = NULL;
msg.FindString("username", &username);
msg.FindString("password", &password);
msg.FindString("resource", &res);
msg->FindString("username", &username);
msg->FindString("password", &password);
msg->FindString("resource", &res);
if ((username == NULL) || (password == NULL)) {
//LOG( kProtocolName, liHigh, "Invalid settings!");
//LOG( kProtocolSignature, liHigh, "Invalid settings!");
printf("Invalid settings");
return B_ERROR;
}
@ -353,7 +352,7 @@ GoogleTalk::Error(const char* message, const char* who)
//LOG("GoogleTalk", liDebug, "GoogleTalk::Error(%s,%s)", message, who);
BMessage msg(IM_ERROR);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
if (who)
msg.AddString("id", who);
msg.AddString("error", message);
@ -369,7 +368,7 @@ GoogleTalk::GotMessage(const char* from, const char* message)
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_MESSAGE_RECEIVED);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", from);
msg.AddString("message", message);
@ -384,7 +383,7 @@ GoogleTalk::MessageSent(const char* to, const char* message)
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_MESSAGE_SENT);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", to);
msg.AddString("message", message);
@ -399,7 +398,7 @@ GoogleTalk::LoggedIn()
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_SET);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddInt32("status", CAYA_ONLINE);
fServerMsgr->SendMessage(&msg);
@ -428,7 +427,7 @@ GoogleTalk::SetAway(bool away)
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_SET);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
if ( away )
msg.AddInt32("status", CAYA_AWAY);
else
@ -445,7 +444,7 @@ GoogleTalk::LoggedOut()
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_SET);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddInt32("status", CAYA_OFFLINE);
fServerMsgr->SendMessage(&msg);
fFullLogged = false;
@ -473,7 +472,7 @@ GoogleTalk::BuddyStatusChanged(JabberPresence* jp)
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_CHANGED);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", jp->GetJid());
msg.AddString("resource", jp->GetResource());
@ -524,7 +523,7 @@ GoogleTalk::BuddyStatusChanged(const char* who, CayaStatus status)
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_CHANGED);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", who);
msg.AddInt32("status", status);
@ -537,7 +536,7 @@ GoogleTalk::Progress(const char* id, const char* message, float progress)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_PROGRESS );
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("progressID", id);
msg.AddString("message", message);
msg.AddFloat("progress", progress);
@ -552,14 +551,14 @@ GoogleTalk::getContact(const char* id)
{
RosterList *rl = getRosterList();
JabberContact* contact = NULL;
//LOG(kProtocolName, liDebug, "getContact %s", id);
//LOG(kProtocolSignature, liDebug, "getContact %s", id);
for(int32 i = 0; i < rl->CountItems(); i++) {
contact = reinterpret_cast<JabberContact*>(getRosterList()->ItemAt(i));
//LOG(kProtocolName, liDebug, "getContact [%3d] GetJID %s", i,contact->GetJid().String());
//LOG(kProtocolSignature, liDebug, "getContact [%3d] GetJID %s", i,contact->GetJid().String());
if (contact->GetJid().ICompare(id) == 0) {
//LOG(kProtocolName, liDebug, "getContact found!");
//LOG(kProtocolSignature, liDebug, "getContact found!");
return contact;
}
}
@ -573,7 +572,7 @@ GoogleTalk::SendContactInfo(const JabberContact* jid)
int32 what = IM_CONTACT_INFO;
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", what);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", jid->GetJid());
msg.AddString("nick", jid->GetName());
@ -622,7 +621,7 @@ GoogleTalk::SendBuddyIcon(const char* id)
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_SET_AVATAR);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", id);
msg.AddData("icondata", B_RAW_TYPE, data.String(), data.Length());
fServerMsgr->SendMessage(&msg);
@ -640,7 +639,7 @@ GoogleTalk::Authorized()
fPerc +=0.3333f;
Progress("GoogleTalk Login", "GoogleTalk: Authorized", fPerc);
//LOG(kProtocolName, liDebug, "GoogleTalk:Login %f - Authorized",fPerc) ;
//LOG(kProtocolSignature, liDebug, "GoogleTalk:Login %f - Authorized",fPerc) ;
CheckLoginStatus();
JabberHandler::Authorized();
@ -660,15 +659,15 @@ GoogleTalk::Message(JabberMessage* message)
return;
}
//LOG(kProtocolName, liHigh, "GETX: '%s'",message->GetX().String()) ;
//LOG(kProtocolSignature, liHigh, "GETX: '%s'",message->GetX().String()) ;
if (message->GetX().ICompare("composing") == 0) {
// Someone send a composing event...
if (message->GetBody() == "") {
//LOG(kProtocolName, liHigh,"CONTACT_STARTED_TYPING");
//LOG(kProtocolSignature, liHigh,"CONTACT_STARTED_TYPING");
BMessage im_msg(IM_MESSAGE);
im_msg.AddInt32("im_what", IM_CONTACT_STARTED_TYPING);
im_msg.AddString("protocol", kProtocolName);
im_msg.AddString("protocol", kProtocolSignature);
im_msg.AddString("id", message->GetFrom());
fServerMsgr->SendMessage(&im_msg);
} else {
@ -683,11 +682,11 @@ GoogleTalk::Message(JabberMessage* message)
// unkown event.
// no event (means stop all)
//LOG(kProtocolName, liHigh,"CONTACT_STOPPED_TYPING");
//LOG(kProtocolSignature, liHigh,"CONTACT_STOPPED_TYPING");
BMessage im_msg(IM_MESSAGE);
im_msg.AddInt32("im_what", IM_CONTACT_STOPPED_TYPING);
im_msg.AddString("protocol", kProtocolName);
im_msg.AddString("protocol", kProtocolSignature);
im_msg.AddString("id", message->GetFrom());
fServerMsgr->SendMessage(&im_msg);
}
@ -706,7 +705,7 @@ GoogleTalk::Roster(RosterList* roster)
{
// Fix me! (Roster message can arrive at different times)
BMessage serverBased(IM_SERVER_BASED_CONTACT_LIST);
serverBased.AddString("protocol", kProtocolName);
serverBased.AddString("protocol", kProtocolSignature);
JabberContact* contact;
int size = roster->CountItems();
@ -729,7 +728,7 @@ GoogleTalk::Roster(RosterList* roster)
Progress("GoogleTalk Login", "GoogleTalk: Roster", fPerc);
}
//LOG(kProtocolName, liDebug, "GoogleTalk:Login %f - Rostered",fPerc) ;
//LOG(kProtocolSignature, liDebug, "GoogleTalk:Login %f - Rostered",fPerc) ;
CheckLoginStatus();
}
@ -740,7 +739,7 @@ GoogleTalk::Agents(AgentList* agents)
fPerc +=0.3333f;
fAgent = true;
Progress("GoogleTalk Login", "GoogleTalk: Agents", fPerc);
//LOG(kProtocolName, liDebug, "GoogleTalk:Login %f - Agents",fPerc) ;
//LOG(kProtocolSignature, liDebug, "GoogleTalk:Login %f - Agents",fPerc) ;
CheckLoginStatus();
}
@ -762,7 +761,7 @@ GoogleTalk::SubscriptionRequest(JabberPresence* presence)
{
BMessage im_msg(IM_MESSAGE);
im_msg.AddInt32("im_what", IM_AUTH_REQUEST);
im_msg.AddString("protocol", kProtocolName);
im_msg.AddString("protocol", kProtocolSignature);
im_msg.AddString("id", presence->GetJid());
im_msg.AddString("message", presence->GetStatus());
@ -779,7 +778,7 @@ GoogleTalk::Unsubscribe(JabberPresence* presence)
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_CHANGED);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", presence->GetJid());
msg.AddInt32("status", CAYA_OFFLINE);
fServerMsgr->SendMessage(&msg);
@ -793,7 +792,7 @@ GoogleTalk::OwnContactInfo(JabberContact* contact)
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", what);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", contact->GetJid());
msg.AddString("nick", contact->GetName());
@ -824,7 +823,7 @@ GoogleTalk::GotBuddyPhoto(const BString& jid, const BString& imagePath)
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_AVATAR_CHANGED);
msg.AddString("protocol", kProtocolName);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", jid);
entry_ref ref;
@ -840,8 +839,8 @@ GoogleTalk::Registration(JabberRegistration* registration)
{
// Just created a new account ?
// or we have ack of a registration? ack of registartion!
debugger("Registration");
registration->PrintToStream();
debugger("Registration");
}

View File

@ -40,16 +40,18 @@ public:
virtual status_t Process( BMessage * );
// Get name of protocol
virtual const char * GetSignature();
virtual const char * GetFriendlySignature();
virtual const char * Signature() const;
virtual const char * FriendlySignature() const;
// settings changed
virtual status_t UpdateSettings( BMessage & );
virtual status_t UpdateSettings( BMessage * );
// preferred encoding of messages
virtual uint32 GetEncoding();
// IM::Protocol part ends here
virtual CayaProtocolMessengerInterface* MessengerInterface() const { return fServerMsgr; }
// JabberManager part begins here
virtual void Error( const char * message, const char * who );
@ -111,4 +113,7 @@ protected:
virtual void GotBuddyPhoto(const BString & jid, const BString & imagePath);
};
extern const char* kProtocolSignature;
extern const char* kProtocolName;
#endif // IMKIT_GoogleTalk_H

View File

@ -10,11 +10,11 @@ AddOn gtalk :
main.cpp
GoogleTalk.cpp
: be libjabber.a ssl crypto $(TARGET_LIBSTDC++) expat
: gtalk.rdef SettingsTemplate.rdef
: gtalk.rdef settings_template.rdef
;
Depends gtalk : libjabber.a ;
LINKFLAGS on gtalk += -L$(OPENSSL_LIBRARY_DIR) ;
InstallBin $(APPS_DIRECTORY)/caya/protocols : gtalk ;
InstallBin $(CAYA_DIRECTORY)/protocols : gtalk ;

View File

@ -1,8 +1,25 @@
#include "GoogleTalk.h"
extern "C" __declspec(dllexport) CayaProtocol *main_protocol ();
extern "C" __declspec(dllexport) CayaProtocol* protocol();
extern "C" __declspec(dllexport) const char* signature();
extern "C" __declspec(dllexport) const char* friendly_signature();
CayaProtocol *main_protocol ()
CayaProtocol*
protocol()
{
return (CayaProtocol *)(new GoogleTalk());
return (CayaProtocol*)new GoogleTalk();
}
const char*
signature()
{
return kProtocolSignature;
}
const char*
friendly_signature()
{
return kProtocolName;
}

View File

@ -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"
}
};

View File

@ -1,87 +1,87 @@
SubDir TOP smileys ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : settings.xml ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : airplane.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : angel_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : angry.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : asl.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : auto.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : baring_teeth.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : bat.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : beer_mug.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : black_sheep.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : bowl.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : brb.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : broken_heart.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : cake.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : camera.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : cat.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : cigarette.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : clock.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : coffee.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : computer.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : confused.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : console.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : cry.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : devil_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : dog.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : dont_know.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : dont_tell.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : envelope.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : film.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : girl.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : girl_hug.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : guy.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : guy_hug.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : hahaha.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : handcuffs.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : heart.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : island_palm.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : kiss.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : lightbulb.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : lightning.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : martini.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : messenger.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : mobile_phone.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : money.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : moon.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : nerd.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : note.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : omg.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : party.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : phone.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : pizaa.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : pizza.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : plate.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : present.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : rainbow.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : red.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : regular_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : regular_smiley.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : roll.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : rose.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : ruler.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : sad_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : sarcastic.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : secret.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : shades.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : sick.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : sleepy.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : smilec.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : snail.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : soccer.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : star.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : star2.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : stormy.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : sun.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : teeth_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : thinking.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : thumbs_down.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : thumbs_up.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : tongue_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : turtle.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : umbrella.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : what_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : wilted_rose.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : wink_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : wu.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : settings.xml ;
InstallFile $(CAYA_DIRECTORY)/smileys : airplane.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : angel_smile.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : angry.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : asl.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : auto.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : baring_teeth.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : bat.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : beer_mug.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : black_sheep.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : bowl.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : brb.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : broken_heart.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : cake.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : camera.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : cat.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : cigarette.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : clock.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : coffee.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : computer.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : confused.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : console.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : cry.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : devil_smile.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : dog.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : dont_know.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : dont_tell.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : envelope.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : film.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : girl.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : girl_hug.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : guy.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : guy_hug.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : hahaha.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : handcuffs.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : heart.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : island_palm.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : kiss.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : lightbulb.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : lightning.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : martini.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : messenger.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : mobile_phone.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : money.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : moon.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : nerd.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : note.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : omg.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : party.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : phone.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : pizaa.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : pizza.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : plate.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : present.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : rainbow.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : red.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : regular_smile.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : regular_smiley.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : roll.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : rose.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : ruler.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : sad_smile.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : sarcastic.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : secret.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : shades.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : sick.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : sleepy.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : smilec.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : snail.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : soccer.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : star.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : star2.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : stormy.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : sun.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : teeth_smile.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : thinking.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : thumbs_down.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : thumbs_up.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : tongue_smile.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : turtle.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : umbrella.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : what_smile.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : wilted_rose.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : wink_smile.gif ;
InstallFile $(CAYA_DIRECTORY)/smileys : wu.gif ;