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 protocols ;
SubInclude TOP smileys ; SubInclude TOP smileys ;
Distro distro ; UninstallTarget $(CAYA_DIRECTORY) ;
FullDistro fulldistro ;
UninstallTarget $(APPS_DIRECTORY)/caya ;

View File

@ -11,7 +11,7 @@ PACKAGE_OBJECT_DIR = [ FDirName $(PACKAGE_DIR) objects ] ;
##------------------------------------------------------------------- ##-------------------------------------------------------------------
## Defines ## Defines
##------------------------------------------------------------------- ##-------------------------------------------------------------------
VERSION = 10 ; VERSION = 0.0.1 ;
DEFINES += VERSION=\"\\\"$(VERSION)\\\"\" ; DEFINES += VERSION=\"\\\"$(VERSION)\\\"\" ;
DEFINES += BUILD_DATE=\"\\\"$(JAMDATE)\\\"\" ; DEFINES += BUILD_DATE=\"\\\"$(JAMDATE)\\\"\" ;
CHGRP = ; 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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Andrea Anzani, andrea.anzani@gmail.com * 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 "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); fProtocol->Init(this);
fMessenger = msgr;
// 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() Account::~Account()
{ {
delete fSettings;
}
bigtime_t
Account::Identifier() const
{
return fIdentifier;
}
const char*
Account::Name() const
{
return fName.String();
} }
status_t status_t
Account::SendMessage(BMessage* message) Account::SendMessage(BMessage* message)
{ {
// This is just an example of what can be done ;) message->AddInt64("instance", fIdentifier);
message->AddPointer("account", (void*)this);
return fMessenger.SendMessage(message); 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. * Distributed under the terms of the MIT License.
*/ */
#ifndef _ACCOUNT_H #ifndef _ACCOUNT_H
@ -7,18 +8,27 @@
#include <Handler.h> #include <Handler.h>
#include <Messenger.h> #include <Messenger.h>
#include <String.h>
#include "CayaProtocol.h" #include "CayaProtocol.h"
class Account : public CayaProtocolMessengerInterface { class Account : public CayaProtocolMessengerInterface {
public: public:
Account(BHandler* msgTarget); Account(bigtime_t instanceId, CayaProtocol* cayap,
virtual ~Account(); 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: private:
BMessenger fMessenger; bigtime_t fIdentifier;
CayaProtocol* fProtocol;
BString fName;
BMessenger fMessenger;
BMessage* fSettings;
}; };
#endif // _ACCOUNT_H #endif // _ACCOUNT_H

View File

@ -7,6 +7,7 @@
*/ */
#include "AccountManager.h" #include "AccountManager.h"
#include "MainWindow.h"
#include "NotifyMessage.h" #include "NotifyMessage.h"
#include "Server.h" #include "Server.h"
#include "TheApp.h" #include "TheApp.h"
@ -49,7 +50,7 @@ AccountManager::SetNickname(BString nick)
// Send message // Send message
TheApp* theApp = reinterpret_cast<TheApp*>(be_app); TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
MainWindow* win = theApp->GetMainWindow(); 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 // Send message
TheApp* theApp = reinterpret_cast<TheApp*>(be_app); TheApp* theApp = reinterpret_cast<TheApp*>(be_app);
MainWindow* win = theApp->GetMainWindow(); MainWindow* win = theApp->GetMainWindow();
win->GetServer()->SendProtocolMessage(msg); win->GetServer()->SendAllProtocolMessage(msg);
// Notify status change // Notify status change
fStatus = status; 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. * Distributed under the terms of the MIT License.
*/ */
#ifndef CayaProtocol_h #ifndef _CAYA_PROTOCOL_H
#define CayaProtocol_h #define _CAYA_PROTOCOL_H
#include <Messenger.h> #include <Messenger.h>
class CayaProtocolMessengerInterface { class CayaProtocolMessengerInterface {
public:
public: virtual status_t SendMessage(BMessage* message) = 0;
virtual status_t SendMessage(BMessage *message) = 0;
}; };
class CayaProtocol class CayaProtocol {
{ public:
public: // Messenger
virtual status_t Init(CayaProtocolMessengerInterface*) = 0;
// messenger // Called before unloading from memory
virtual status_t Init( CayaProtocolMessengerInterface * ) = 0; virtual status_t Shutdown() = 0;
// called before unloading from memory // Process message
virtual status_t Shutdown() = 0; virtual status_t Process(BMessage*) = 0;
// process message // Change settings
virtual status_t Process( BMessage * ) = 0; virtual status_t UpdateSettings(BMessage*) = 0;
// Get name of protocol // Protocol information
virtual const char * GetSignature() = 0; virtual const char* Signature() const = 0;
virtual const char * GetFriendlySignature() = 0; virtual const char* FriendlySignature() const = 0;
// settings changed // Preferred encoding of messages
virtual status_t UpdateSettings( BMessage & ) = 0; virtual uint32 GetEncoding() = 0;
// preferred encoding of messages // Messenger interface used
virtual uint32 GetEncoding() = 0; virtual CayaProtocolMessengerInterface* MessengerInterface() const = 0;
}; };
#endif // _CAYA_PROTOCOL_H
#endif

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

View File

@ -8,6 +8,7 @@
#include <stdio.h> #include <stdio.h>
#include "CayaProtocolAddOn.h"
#include "ChatWindow.h" #include "ChatWindow.h"
#include "ContactLinker.h" #include "ContactLinker.h"
#include "ContactPopUp.h" #include "ContactPopUp.h"
@ -22,6 +23,7 @@ ContactLinker::ContactLinker(BString id, BMessenger msgn)
fID(id), fID(id),
fName(id), fName(id),
fMessenger(msgn), fMessenger(msgn),
fLooper(NULL),
fStatus(CAYA_OFFLINE), fStatus(CAYA_OFFLINE),
fPopUp(NULL) fPopUp(NULL)
{ {
@ -30,7 +32,8 @@ ContactLinker::ContactLinker(BString id, BMessenger msgn)
RegisterObserver(fRosterItem); RegisterObserver(fRosterItem);
// By default we use protocol icon as avatar icon // 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 void
ContactLinker::SetNotifyName(BString name) ContactLinker::SetNotifyName(BString name)
{ {

View File

@ -16,6 +16,7 @@ class BBitmap;
class ChatWindow; class ChatWindow;
class ContactPopUp; class ContactPopUp;
class ProtocolLooper;
class RosterItem; class RosterItem;
class ContactLinker : public Notifier { class ContactLinker : public Notifier {
@ -36,7 +37,11 @@ public:
BString GetId() { return fID; } 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; } BString GetName() { return fName; }
BBitmap* AvatarBitmap() { return fAvatarBitmap; } BBitmap* AvatarBitmap() { return fAvatarBitmap; }
@ -52,8 +57,10 @@ private:
RosterItem* fRosterItem; RosterItem* fRosterItem;
ChatWindow* fChatWindow; ChatWindow* fChatWindow;
BMessenger fMessenger; BMessenger fMessenger;
ProtocolLooper* fLooper;
BString fID; BString fID;
bigtime_t fInstance;
BString fName; BString fName;
BString fPersonalStatus; BString fPersonalStatus;
BBitmap* fAvatarBitmap; BBitmap* fAvatarBitmap;

View File

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

View File

@ -15,19 +15,20 @@ local svnRevisionFile = [ FGristFiles svn_revision ] ;
MakeLocate $(svnRevisionFile) : $(LOCATE_TARGET) ; MakeLocate $(svnRevisionFile) : $(LOCATE_TARGET) ;
CreateSVNRevisionFile $(svnRevisionFile) ; CreateSVNRevisionFile $(svnRevisionFile) ;
Application caya : Application Caya :
AboutWindow.cpp AboutWindow.cpp
Account.cpp Account.cpp
AccountManager.cpp AccountManager.cpp
CayaProtocolAddOn.cpp
CayaUtils.cpp CayaUtils.cpp
ChatWindow.cpp ChatWindow.cpp
ContactLinker.cpp ContactLinker.cpp
EditingFilter.cpp EditingFilter.cpp
ImageCache.cpp ImageCache.cpp
LooperCayaProtocol.cpp
Main.cpp Main.cpp
MainWindow.cpp MainWindow.cpp
Notifier.cpp Notifier.cpp
ProtocolLooper.cpp
ProtocolManager.cpp ProtocolManager.cpp
ProtocolSettings.cpp ProtocolSettings.cpp
Server.cpp Server.cpp
@ -56,10 +57,10 @@ Application caya :
: Caya.rdef : Caya.rdef
; ;
Depends caya : libjabber.a ; Depends Caya : libjabber.a ;
Depends caya : librunview.a ; Depends Caya : librunview.a ;
Depends caya : libinterface.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 <libinterface/ToolButton.h>
#include "CayaConstants.h" #include "CayaConstants.h"
#include "CayaMessages.h"
#include "CayaResources.h" #include "CayaResources.h"
#include "CayaUtils.h" #include "CayaUtils.h"
#include "NotifyMessage.h" #include "NotifyMessage.h"
@ -48,38 +49,16 @@ const uint32 kSearchContact = 'SRCH';
const uint32 kPreferences = 'WPRF'; const uint32 kPreferences = 'WPRF';
MainWindow::MainWindow() : MainWindow::MainWindow()
BWindow(BRect(0, 0, 300, 400), "Caya", B_DOCUMENT_WINDOW, 0) : 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"); fStatusView = new StatusView("statusView");
BTextControl* searchBox = new BTextControl("searchBox", NULL, NULL, BTextControl* searchBox = new BTextControl("searchBox", NULL, NULL,
new BMessage(kSearchContact)); new BMessage(kSearchContact));
BBox* rosterView = new BBox("rosterView");
fListView = new RosterListView("buddyView"); fListView = new RosterListView("buddyView");
fListView->SetInvocationMessage(new BMessage(OPEN_WINDOW)); fListView->SetInvocationMessage(new BMessage(CAYA_OPEN_WINDOW));
BScrollView* scrollView = new BScrollView("scrollview", fListView, BScrollView* scrollView = new BScrollView("scrollview", fListView,
B_WILL_DRAW, false, true); B_WILL_DRAW, false, true);
@ -105,8 +84,8 @@ MainWindow::MainWindow() :
wrench->SetBitmap(toolIcon); wrench->SetBitmap(toolIcon);
wrench->SetMenu(wrenchMenu); wrench->SetMenu(wrenchMenu);
rosterView->SetLayout(new BGridLayout(5, 5)); SetLayout(new BGridLayout(5, 5));
rosterView->AddChild(BGridLayoutBuilder(5, 0) AddChild(BGridLayoutBuilder(5, 5)
.Add(fStatusView, 0, 0) .Add(fStatusView, 0, 0)
.Add(wrench, 1, 0) .Add(wrench, 1, 0)
.Add(searchBox, 0, 1) .Add(searchBox, 0, 1)
@ -114,27 +93,30 @@ MainWindow::MainWindow() :
.SetInsets(5, 5, 5, 10) .SetInsets(5, 5, 5, 10)
); );
fStack->AddView(rosterView);
fStack->SetVisibleItem((long)0);
AddShortcut('a', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED)); AddShortcut('a', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED));
MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2)); MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));
fPassword->TextView()->HideTyping(true); // Filter messages using Server
fUsername->MakeFocus(true); fServer = new Server();
AddFilter(fServer);
fSrv = new Server(this);
AddFilter(fSrv);
CenterOnScreen(); CenterOnScreen();
} }
void
MainWindow::Start()
{
// Login all accounts
fServer->LoginAll();
}
bool bool
MainWindow::QuitRequested() MainWindow::QuitRequested()
{ {
fListView->MakeEmpty(); fListView->MakeEmpty();
fSrv->Quit(); fServer->Quit();
be_app->PostMessage(B_QUIT_REQUESTED); be_app->PostMessage(B_QUIT_REQUESTED);
return true; return true;
} }
@ -143,27 +125,8 @@ MainWindow::QuitRequested()
void void
MainWindow::MessageReceived(BMessage* message) MainWindow::MessageReceived(BMessage* message)
{ {
switch(message->what) { switch (message->what) {
case kLogin: case kSearchContact: {
{
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:
{
void* control = NULL; void* control = NULL;
if (message->FindPointer("source", &control) != B_OK) if (message->FindPointer("source", &control) != B_OK)
return; return;
@ -172,7 +135,7 @@ MainWindow::MessageReceived(BMessage* message)
if (searchBox == NULL) if (searchBox == NULL)
return; return;
RosterMap map = fSrv->RosterItems(); RosterMap map = fServer->RosterItems();
for (uint32 i = 0; i < map.CountItems(); i++) { for (uint32 i = 0; i < map.CountItems(); i++) {
ContactLinker* linker = map.ValueAt(i); ContactLinker* linker = map.ValueAt(i);
RosterItem* item = linker->GetRosterItem(); RosterItem* item = linker->GetRosterItem();
@ -195,6 +158,13 @@ MainWindow::MessageReceived(BMessage* message)
dialog->Show(); dialog->Show();
break; break;
} }
case CAYA_OPEN_WINDOW: {
int index = message->FindInt32("index");
RosterItem* ritem = ItemAt(index);
if (ritem != NULL)
ritem->GetContactLinker()->ShowWindow();
break;
}
case IM_MESSAGE: case IM_MESSAGE:
ImMessage(message); ImMessage(message);
break; break;
@ -209,20 +179,21 @@ MainWindow::MessageReceived(BMessage* message)
} }
} }
void void
MainWindow::ImError(BMessage* msg) MainWindow::ImError(BMessage* msg)
{ {
//FIXME: better error handling.. //FIXME: better error handling..
BAlert* alert = new BAlert("Error", msg->FindString("error"), "Ouch!"); BAlert* alert = new BAlert("Error", msg->FindString("error"), "Ouch!");
alert->Go(); alert->Go();
fStack->SetVisibleItem((long)0);
} }
void void
MainWindow::ImMessage(BMessage* msg) MainWindow::ImMessage(BMessage* msg)
{ {
int32 im_what = msg->FindInt32("im_what"); int32 im_what = msg->FindInt32("im_what");
switch(im_what) { switch (im_what) {
case IM_OWN_CONTACT_INFO: case IM_OWN_CONTACT_INFO:
{ {
fStatusView->SetName(msg->FindString("nick")); fStatusView->SetName(msg->FindString("nick"));
@ -241,7 +212,7 @@ MainWindow::ImMessage(BMessage* msg)
if (msg->FindInt32("status", &status) != B_OK) if (msg->FindInt32("status", &status) != B_OK)
return; return;
RosterItem* rosterItem = fSrv->RosterItemForId(msg->FindString("id")); RosterItem* rosterItem = fServer->RosterItemForId(msg->FindString("id"));
if (rosterItem) { if (rosterItem) {
// Add or remove item // Add or remove item
@ -266,7 +237,7 @@ MainWindow::ImMessage(BMessage* msg)
case IM_AVATAR_CHANGED: case IM_AVATAR_CHANGED:
case IM_CONTACT_INFO: case IM_CONTACT_INFO:
{ {
RosterItem* rosterItem = fSrv->RosterItemForId(msg->FindString("id")); RosterItem* rosterItem = fServer->RosterItemForId(msg->FindString("id"));
if (rosterItem) if (rosterItem)
UpdateListItem(rosterItem); UpdateListItem(rosterItem);
break; break;

View File

@ -18,13 +18,12 @@ class StatusView;
class RosterListView; class RosterListView;
class RosterItem; class RosterItem;
#define OPEN_WINDOW 'opwn'
#define CLOSE_WINDOW 'clwn'
class MainWindow: public BWindow, public Observer { class MainWindow: public BWindow, public Observer {
public: public:
MainWindow(); MainWindow();
void Start();
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
void ImMessage(BMessage* msg); void ImMessage(BMessage* msg);
void ImError(BMessage* msg); void ImError(BMessage* msg);
@ -32,7 +31,7 @@ public:
void ObserveInteger(int32 what, int32 val); void ObserveInteger(int32 what, int32 val);
Server* GetServer() const { return fSrv; } Server* GetServer() const { return fServer; }
void UpdateListItem(RosterItem* item); void UpdateListItem(RosterItem* item);
@ -45,10 +44,7 @@ public:
private: private:
StatusView* fStatusView; StatusView* fStatusView;
RosterListView* fListView; RosterListView* fListView;
BCardLayout* fStack; Server* fServer;
BTextControl* fUsername;
BTextControl* fPassword;
Server* fSrv;
}; };
#endif // _MAIN_WINDOW_H #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 <stdio.h>
#include <Entry.h>
#include <image.h> #include <image.h>
#include <libinterface/BitmapUtils.h> #include <Directory.h>
#include <Entry.h>
#include <Handler.h>
#include "Account.h"
#include "ProtocolManager.h" #include "ProtocolManager.h"
#include "CayaProtocol.h" #include "CayaProtocol.h"
#include "CayaUtils.h" #include "CayaUtils.h"
#include "MainWindow.h"
#include "Server.h"
#include "TheApp.h"
static ProtocolManager* fInstance = NULL; static ProtocolManager* fInstance = NULL;
void void
ProtocolManager::Init(BDirectory protocolDir) ProtocolManager::Init(BDirectory dir, BHandler* target)
{ {
BEntry entry; BEntry entry;
BPath path; BPath path;
protocolDir.Rewind(); dir.Rewind();
while (protocolDir.GetNextEntry(&entry) == B_OK) { while (dir.GetNextEntry(&entry) == B_OK) {
path = BPath(&entry); path = BPath(&entry);
// Load protocol addon
image_id id = load_add_on(path.Path()); image_id id = load_add_on(path.Path());
if (id >= 0) { if (id < 0)
CayaProtocol* (*main_protocol)(); continue;
if (get_image_symbol(id, "main_protocol", B_SYMBOL_TYPE_TEXT,
(void**)&main_protocol) == B_OK) {
CayaProtocol* cayp = (*main_protocol)();
if (cayp) { CayaProtocolAddOn* addOn = new CayaProtocolAddOn(id, path.Path());
printf("Found a new Protocol: %s [%s]\n", cayp->GetFriendlySignature(), fAddOnMap.AddItem(addOn->Signature(), addOn);
cayp->GetSignature());
fProtocolMap.AddItem(BString(cayp->GetSignature()), cayp); _GetAccounts(addOn, target);
fAddonMap.AddItem(BString(cayp->GetSignature()), new BPath(path));
} else
unload_add_on(id);
} else
unload_add_on(id);
}
} }
} }
@ -66,30 +62,69 @@ ProtocolManager::Get()
} }
ProtocolAddOns
ProtocolManager::Protocols()
{
return fAddOnMap.Values();
}
ProtocolMap
ProtocolManager::ProtocolInstances() const
{
return fProtocolMap;
}
CayaProtocol* CayaProtocol*
ProtocolManager::GetProtocol(BString signature) ProtocolManager::ProtocolInstance(bigtime_t identifier)
{ {
return fProtocolMap.ValueFor(signature); return fProtocolMap.ValueFor(identifier);
} }
BList* CayaProtocolAddOn*
ProtocolManager::GetProtocols() ProtocolManager::ProtocolAddOn(const char* signature)
{ {
return fProtocolMap.Items(); return fAddOnMap.ValueFor(signature);
} }
BPath* void
ProtocolManager::GetProtocolPath(BString signature) 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* void
ProtocolManager::GetProtocolIcon(BString signature) ProtocolManager::_GetAccounts(CayaProtocolAddOn* addOn, BHandler* target)
{ {
BPath* path = fAddonMap.ValueFor(signature); // Find accounts path for this protocol
return ReadNodeIcon(path->Path(), B_LARGE_ICON, true); 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. * Distributed under the terms of the MIT License.
*/ */
#ifndef ProtocolManager_h #ifndef _PROTOCOL_MANAGER_H
#define ProtocolManager_h #define _PROTOCOL_MANAGER_H
#include <Directory.h>
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
#include <libs/libsupport/KeyMap.h> #include <libsupport/KeyMap.h>
#include "CayaProtocol.h" #include "CayaProtocol.h"
#include "CayaProtocolAddOn.h"
class BBitmap; 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: public:
void Init(BDirectory protocolDir); void Init(BDirectory dir, BHandler* target);
static ProtocolManager* Get();
CayaProtocol* GetProtocol(BString signature); static ProtocolManager* Get();
BList* GetProtocols(); ProtocolAddOns Protocols();
ProtocolMap ProtocolInstances() const;
BPath* GetProtocolPath(BString signature); CayaProtocol* ProtocolInstance(bigtime_t identifier);
BBitmap* GetProtocolIcon(BString signature); 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; AddOnMap fAddOnMap;
KeyMap<BString, BPath*> fAddonMap; ProtocolMap fProtocolMap;
}; };
#endif
#endif // _PROTOCOL_MANAGER_H

View File

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

View File

@ -9,26 +9,28 @@
#include <libsupport/List.h> #include <libsupport/List.h>
class BMessage; class BMessage;
class CayaProtocol; class CayaProtocolAddOn;
class ProtocolSettings { class ProtocolSettings {
public: public:
ProtocolSettings(CayaProtocol* cayap); ProtocolSettings(CayaProtocolAddOn* addOn);
~ProtocolSettings(); ~ProtocolSettings();
status_t InitCheck() const; status_t InitCheck() const;
CayaProtocol* Protocol() const; CayaProtocolAddOn* AddOn() const;
List<BString> Accounts() const; List<BString> Accounts() const;
status_t LoadTemplate(BView* parent); status_t LoadTemplate(BView* parent);
status_t Load(const char* account, BView* parent); status_t Load(const char* account, BView* parent);
status_t Save(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); status_t Delete(const char* account);
private: private:
status_t fStatus; status_t fStatus;
CayaProtocol* fProtocol; CayaProtocolAddOn* fAddOn;
BString fAccount; BString fAccount;
BMessage* fTemplate; 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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -8,36 +9,26 @@
*/ */
#include <Application.h> #include <Application.h>
#include <Debug.h>
#include <Entry.h> #include <Entry.h>
#include <Path.h> #include <Path.h>
#include <TranslationUtils.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 "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) : 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() Server::Quit()
{ {
ContactLinker* linker = NULL; ContactLinker* linker = NULL;
while ((linker = fRosterMap.ValueAt(0))) { while ((linker = fRosterMap.ValueAt(0))) {
linker->DeleteWindow(); linker->DeleteWindow();
linker->DeletePopUp(); linker->DeletePopUp();
@ -54,27 +46,74 @@ Server::Quit()
void void
Server::Login() Server::AddProtocolLooper(bigtime_t instanceId, CayaProtocol* cayap)
{ {
BMessage* msg = new BMessage(IM_MESSAGE); ProtocolLooper* looper = new ProtocolLooper(cayap);
msg->AddInt32("im_what", IM_SET_STATUS); fLoopers.AddItem(instanceId, looper);
msg->AddInt32("status", CAYA_ONLINE);
fProtocol->PostMessage(msg);
} }
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 void
Server::SendProtocolMessage(BMessage* msg) Server::SendProtocolMessage(BMessage* msg)
{ {
if (msg != NULL) // Skip null messages
fProtocol->PostMessage(msg); 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 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; bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found); ContactLinker* item = fRosterMap.ValueFor(id, &found);
if (!found) { if (found)
item = new ContactLinker(id.String(), Looper()); continue;
fRosterMap.AddItem(id, item);
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; result = B_SKIP_MESSAGE;
break; break;
} }
case OPEN_WINDOW: case CAYA_CLOSE_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:
{ {
BString id = message->FindString("id"); BString id = message->FindString("id");
if (id != "") { if (id.Length() > 0) {
bool found = false; bool found = false;
ContactLinker *item = fRosterMap.ValueFor(id, &found); ContactLinker *item = fRosterMap.ValueFor(id, &found);
@ -125,6 +172,9 @@ Server::Filter(BMessage* message, BHandler **target)
case IM_MESSAGE: case IM_MESSAGE:
result = ImMessage(message); result = ImMessage(message);
break; break;
default:
// Dispatch not handled messages to main window
break;
} }
return result; return result;
@ -175,14 +225,15 @@ Server::ImMessage(BMessage* msg)
if (msg->FindInt32("status", &status) != B_OK) if (msg->FindInt32("status", &status) != B_OK)
return B_SKIP_MESSAGE; return B_SKIP_MESSAGE;
ContactLinker* linker = EnsureContactLinker(msg->FindString("id")); ContactLinker* linker = _EnsureContactLinker(msg);
linker->SetNotifyStatus((CayaStatus)status); linker->SetNotifyStatus((CayaStatus)status);
linker->SetNotifyPersonalStatus(msg->FindString("message")); linker->SetNotifyPersonalStatus(msg->FindString("message"));
break; break;
} }
case IM_CONTACT_INFO: case IM_CONTACT_INFO:
{ {
ContactLinker* linker = EnsureContactLinker(msg->FindString("id")); ContactLinker* linker = _EnsureContactLinker(msg);
BString fullName = msg->FindString("nick"); BString fullName = msg->FindString("nick");
if (fullName != "") if (fullName != "")
linker->SetNotifyName(fullName); linker->SetNotifyName(fullName);
@ -190,7 +241,7 @@ Server::ImMessage(BMessage* msg)
} }
case IM_AVATAR_CHANGED: case IM_AVATAR_CHANGED:
{ {
ContactLinker* linker = EnsureContactLinker(msg->FindString("id")); ContactLinker* linker = _EnsureContactLinker(msg);
entry_ref ref; entry_ref ref;
if (linker) { if (linker) {
if (msg->FindRef("ref", &ref) == B_OK) { if (msg->FindRef("ref", &ref) == B_OK) {
@ -203,13 +254,17 @@ Server::ImMessage(BMessage* msg)
} }
break; break;
} }
case IM_SEND_MESSAGE: case IM_SEND_MESSAGE: {
fProtocol->PostMessage(msg); // Route this message through the appropriate ProtocolLooper
ContactLinker* linker = _EnsureContactLinker(msg);
if (linker->GetProtocolLooper())
linker->GetProtocolLooper()->PostMessage(msg);
break; break;
}
case IM_MESSAGE_RECEIVED: case IM_MESSAGE_RECEIVED:
{ {
BString id = msg->FindString("id"); BString id = msg->FindString("id");
if (id != "") { if (id.Length() > 0) {
bool found = false; bool found = false;
ContactLinker* item = fRosterMap.ValueFor(id, &found); ContactLinker* item = fRosterMap.ValueFor(id, &found);
if (found) { if (found) {
@ -222,7 +277,6 @@ Server::ImMessage(BMessage* msg)
break; break;
} }
default: default:
msg->PrintToStream();
break; break;
} }
@ -231,24 +285,51 @@ Server::ImMessage(BMessage* msg)
ContactLinker* 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; ContactLinker* item = NULL;
if (id != "") {
if (id.Length() > 0) {
bool found = false; bool found = false;
item = fRosterMap.ValueFor(id, &found); item = fRosterMap.ValueFor(id, &found);
if (!found) { if (!found) {
item = new ContactLinker(id.String(), Looper()); item = new ContactLinker(id.String(), Looper());
item->SetProtocolLooper(_LooperFromMessage(message));
fRosterMap.AddItem(id, item); fRosterMap.AddItem(id, item);
} }
} }
return 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. * Distributed under the terms of the MIT License.
*/ */
#ifndef _SERVER_H #ifndef _SERVER_H
@ -13,40 +14,46 @@
#include "CayaConstants.h" #include "CayaConstants.h"
#include "ContactLinker.h" #include "ContactLinker.h"
class MainWindow; class CayaProtocol;
class RosterItem; class RosterItem;
class LooperCayaProtocol; class ProtocolLooper;
typedef KeyMap<BString, ContactLinker*> RosterMap; typedef KeyMap<BString, ContactLinker*> RosterMap;
typedef KeyMap<bigtime_t, ProtocolLooper*> ProtocolLoopers;
class Server: public BMessageFilter { class Server: public BMessageFilter {
public: public:
Server(MainWindow* mainWindow); Server();
virtual filter_result Filter(BMessage* message, BHandler** target); virtual filter_result Filter(BMessage* message, BHandler** target);
filter_result ImMessage(BMessage* msg); 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 SendProtocolMessage(BMessage* msg);
void SendChatMessage(BMessage* msg); void SendAllProtocolMessage(BMessage* msg);
RosterMap RosterItems() const; RosterMap RosterItems() const;
RosterItem* RosterItemForId(BString id); RosterItem* RosterItemForId(BString id);
void Quit();
//TODO: there should be a contact for each account. //TODO: there should be a contact for each account.
ContactLinker* GetOwnContact(); ContactLinker* GetOwnContact();
private: private:
ContactLinker* EnsureContactLinker(BString id); ProtocolLooper* _LooperFromMessage(BMessage* message);
ContactLinker* _EnsureContactLinker(BMessage* message);
RosterMap fRosterMap; RosterMap fRosterMap;
MainWindow* fMainWindow; ProtocolLoopers fLoopers;
LooperCayaProtocol* fProtocol;
ContactLinker* fMySelf; ContactLinker* fMySelf;
}; };

View File

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

View File

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

View File

@ -6,6 +6,7 @@
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com * Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
*/ */
#include <Alert.h>
#include <Button.h> #include <Button.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <GroupLayout.h> #include <GroupLayout.h>
@ -19,30 +20,29 @@
#include "AccountView.h" #include "AccountView.h"
#include "ProtocolSettings.h" #include "ProtocolSettings.h"
const uint32 kCancel = 'CANC'; const uint32 kCancel = 'canc';
const uint32 kOK = 'SAVE'; const uint32 kOK = 'save';
AccountDialog::AccountDialog(const char* title, CayaProtocol* cayap, AccountDialog::AccountDialog(const char* title, ProtocolSettings* settings,
const char* account) const char* account)
: BWindow(BRect(0, 0, 1, 1), title, B_MODAL_WINDOW, B_NOT_RESIZABLE | : 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 = new BTextControl("accountName", "Account name:", NULL, NULL);
fAccountName->SetExplicitMinSize(BSize(300, B_SIZE_UNSET));
fAccountName->SetFont(be_bold_font); fAccountName->SetFont(be_bold_font);
if (account) {
fAccountName->SetText(account); fAccountName->SetText(fAccount.String());
fAccountName->SetEnabled(false);
} else
fAccountName->MakeFocus(true);
Divider* divider = new Divider("divider", B_WILL_DRAW); Divider* divider = new Divider("divider", B_WILL_DRAW);
fTop = new AccountView("top"); fTop = new AccountView("top");
if (account) if (fAccount.Length() > 0)
fSettings->Load(account, fTop); fSettings->Load(fAccount.String(), fTop);
else else
fSettings->LoadTemplate(fTop); fSettings->LoadTemplate(fTop);
@ -65,24 +65,69 @@ AccountDialog::AccountDialog(const char* title, CayaProtocol* cayap,
.SetInsets(spacing, spacing, spacing, 0) .SetInsets(spacing, spacing, spacing, 0)
); );
fAccountName->MakeFocus(true);
CenterOnScreen(); CenterOnScreen();
} }
void
AccountDialog::SetTarget(BHandler* target)
{
fTarget = target;
}
void void
AccountDialog::MessageReceived(BMessage* msg) AccountDialog::MessageReceived(BMessage* msg)
{ {
switch (msg->what) { switch (msg->what) {
case kOK: case kOK: {
if (fSettings->Save(fAccountName->Text(), fTop) == B_OK) // 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(); 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; break;
}
case kCancel: case kCancel:
Close(); Close();
break; break;
case kChanged: case kChanged:
msg->PrintToStream();
break; break;
default: default:
BWindow::MessageReceived(msg); BWindow::MessageReceived(msg);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,7 +24,7 @@
#include "StatusMenuItem.h" #include "StatusMenuItem.h"
#include "StatusView.h" #include "StatusView.h"
const int32 kSetNickname = 'NICH'; const int32 kSetNickname = 'stnk';
StatusView::StatusView(const char* name) 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) ; PREFERENCES_DIRECTORY = $(finddir B_PREFERENCES_DIRECTORY) ;
USER_PREFERENCES_DIRECTORY = $(finddir B_USER_CONFIG_DIRECTORY)/be/Preferences ; USER_PREFERENCES_DIRECTORY = $(finddir B_USER_CONFIG_DIRECTORY)/be/Preferences ;
APPS_DIRECTORY = $(finddir B_APPS_DIRECTORY) ; APPS_DIRECTORY = $(finddir B_APPS_DIRECTORY) ;
CAYA_DIRECTORY = $(finddir B_APPS_DIRECTORY)/Caya ;
DEFINES += ${defines} ; DEFINES += ${defines} ;
EOF EOF

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,11 +10,11 @@ AddOn gtalk :
main.cpp main.cpp
GoogleTalk.cpp GoogleTalk.cpp
: be libjabber.a ssl crypto $(TARGET_LIBSTDC++) expat : be libjabber.a ssl crypto $(TARGET_LIBSTDC++) expat
: gtalk.rdef SettingsTemplate.rdef : gtalk.rdef settings_template.rdef
; ;
Depends gtalk : libjabber.a ; Depends gtalk : libjabber.a ;
LINKFLAGS on gtalk += -L$(OPENSSL_LIBRARY_DIR) ; 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" #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 ; SubDir TOP smileys ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : settings.xml ; InstallFile $(CAYA_DIRECTORY)/smileys : settings.xml ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : airplane.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : airplane.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : angel_smile.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : angel_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : angry.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : angry.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : asl.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : asl.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : auto.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : auto.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : baring_teeth.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : baring_teeth.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : bat.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : bat.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : beer_mug.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : beer_mug.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : black_sheep.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : black_sheep.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : bowl.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : bowl.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : brb.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : brb.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : broken_heart.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : broken_heart.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : cake.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : cake.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : camera.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : camera.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : cat.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : cat.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : cigarette.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : cigarette.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : clock.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : clock.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : coffee.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : coffee.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : computer.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : computer.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : confused.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : confused.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : console.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : console.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : cry.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : cry.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : devil_smile.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : devil_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : dog.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : dog.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : dont_know.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : dont_know.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : dont_tell.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : dont_tell.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : envelope.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : envelope.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : film.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : film.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : girl.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : girl.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : girl_hug.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : girl_hug.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : guy.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : guy.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : guy_hug.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : guy_hug.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : hahaha.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : hahaha.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : handcuffs.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : handcuffs.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : heart.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : heart.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : island_palm.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : island_palm.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : kiss.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : kiss.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : lightbulb.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : lightbulb.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : lightning.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : lightning.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : martini.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : martini.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : messenger.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : messenger.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : mobile_phone.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : mobile_phone.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : money.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : money.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : moon.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : moon.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : nerd.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : nerd.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : note.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : note.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : omg.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : omg.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : party.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : party.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : phone.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : phone.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : pizaa.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : pizaa.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : pizza.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : pizza.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : plate.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : plate.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : present.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : present.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : rainbow.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : rainbow.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : red.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : red.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : regular_smile.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : regular_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : regular_smiley.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : regular_smiley.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : roll.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : roll.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : rose.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : rose.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : ruler.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : ruler.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : sad_smile.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : sad_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : sarcastic.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : sarcastic.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : secret.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : secret.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : shades.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : shades.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : sick.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : sick.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : sleepy.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : sleepy.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : smilec.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : smilec.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : snail.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : snail.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : soccer.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : soccer.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : star.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : star.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : star2.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : star2.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : stormy.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : stormy.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : sun.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : sun.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : teeth_smile.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : teeth_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : thinking.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : thinking.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : thumbs_down.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : thumbs_down.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : thumbs_up.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : thumbs_up.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : tongue_smile.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : tongue_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : turtle.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : turtle.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : umbrella.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : umbrella.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : what_smile.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : what_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : wilted_rose.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : wilted_rose.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : wink_smile.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : wink_smile.gif ;
InstallFile $(APPS_DIRECTORY)/caya/smileys : wu.gif ; InstallFile $(CAYA_DIRECTORY)/smileys : wu.gif ;