Some style violations fixed.

This commit is contained in:
plfiorini 2010-05-20 21:31:55 +00:00
parent 8477dae359
commit 88c5eedc9b
19 changed files with 119 additions and 138 deletions

View File

@ -17,7 +17,7 @@
Account::Account(bigtime_t instanceId, CayaProtocol* cayap, Account::Account(bigtime_t instanceId, CayaProtocol* cayap,
const char* name, BHandler* target) const char* name, BHandler* target)
: :
fIdentifier(instanceId), fIdentifier(instanceId),
fName(name), fName(name),
@ -63,6 +63,6 @@ Account::Name() const
status_t status_t
Account::SendMessage(BMessage* message) Account::SendMessage(BMessage* message)
{ {
message->AddInt64("instance", fIdentifier); message->AddInt64("instance", fIdentifier);
return fMessenger.SendMessage(message); return fMessenger.SendMessage(message);
} }

View File

@ -15,14 +15,14 @@ public:
void SetNickname(BString nick); void SetNickname(BString nick);
CayaStatus Status() const; CayaStatus Status() const;
void SetStatus(CayaStatus status, const char* str = NULL); void SetStatus(CayaStatus status,
const char* str = NULL);
private: private:
AccountManager(); AccountManager();
~AccountManager(); ~AccountManager();
CayaStatus fStatus; CayaStatus fStatus;
//BObjectList<Account*> fAccounts;
}; };
#endif // _ACCOUNT_MANAGER_H #endif // _ACCOUNT_MANAGER_H

View File

@ -5,6 +5,6 @@
#ifndef _CAYA_H #ifndef _CAYA_H
#define _CAYA_H #define _CAYA_H
#define CAYA_SIGNATURE "application/x-vnd.xeD.Caya" #define CAYA_SIGNATURE "application/x-vnd.caya.Caya"
#endif // _CAYA_H #endif // _CAYA_H

View File

@ -11,7 +11,7 @@ enum {
kBusyIcon = 12, kBusyIcon = 12,
kOfflineIcon = 13, kOfflineIcon = 13,
kToolIcon = 20, kToolIcon = 20,
kSearchIcon = 21, kSearchIcon = 21,
kProtocolSettingsTemplate = 1000 kProtocolSettingsTemplate = 1000

View File

@ -101,8 +101,8 @@ our_image(image_info& image)
int32 cookie = 0; int32 cookie = 0;
while (get_next_image_info(team, &cookie, &image) == B_OK) { while (get_next_image_info(team, &cookie, &image) == B_OK) {
if ((char *)our_image >= (char *)image.text if ((char*)our_image >= (char*)image.text
&& (char *)our_image <= (char *)image.text + image.text_size) && (char*)our_image <= (char*)image.text + image.text_size)
return B_OK; return B_OK;
} }

View File

@ -40,8 +40,8 @@ ChatWindow::ChatWindow(ContactLinker* cl)
{ {
fReceiveView = new CayaRenderView("fReceiveView"); fReceiveView = new CayaRenderView("fReceiveView");
fReceiveView->SetOtherNick(cl->GetName()); fReceiveView->SetOtherNick(cl->GetName());
BScrollView* scrollViewReceive = new BScrollView("scrollviewR", fReceiveView, BScrollView* scrollViewReceive = new BScrollView("scrollviewR",
B_WILL_DRAW, false, true); fReceiveView, B_WILL_DRAW, false, true);
fSendView = new BTextView("fReceiveView"); fSendView = new BTextView("fReceiveView");
BScrollView* scrollViewSend = new BScrollView("scrollviewS", fSendView, BScrollView* scrollViewSend = new BScrollView("scrollviewS", fSendView,
@ -61,7 +61,6 @@ ChatWindow::ChatWindow(ContactLinker* cl)
MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2)); MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));
fSendView->MakeFocus(true); fSendView->MakeFocus(true);
} }
@ -128,7 +127,7 @@ ChatWindow::ObserveString(int32 what, BString str)
{ {
switch (what) { switch (what) {
case STR_CONTACT_NAME: case STR_CONTACT_NAME:
if (Lock()){ if (Lock()) {
SetTitle(str); SetTitle(str);
fReceiveView->SetOtherNick(str); fReceiveView->SetOtherNick(str);
Unlock(); Unlock();
@ -176,15 +175,15 @@ ChatWindow::AppendStatus(CayaStatus status)
case CAYA_EXTENDED_AWAY: case CAYA_EXTENDED_AWAY:
case CAYA_AWAY: case CAYA_AWAY:
message << " is away"; message << " is away";
break; break;
case CAYA_DO_NOT_DISTURB: case CAYA_DO_NOT_DISTURB:
message << " is busy, please do not disturb!"; message << " is busy, please do not disturb!";
break; break;
case CAYA_OFFLINE: case CAYA_OFFLINE:
message << " is offline"; message << " is offline";
break; break;
default: default:
break; break;
} }
fReceiveView->Append(message.String(), COL_TEXT, COL_TEXT, R_TEXT); fReceiveView->Append(message.String(), COL_TEXT, COL_TEXT, R_TEXT);

View File

@ -2,39 +2,36 @@
* Copyright 2009, Andrea Anzani. All rights reserved. * Copyright 2009, Andrea Anzani. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef ChatWindow_H_ #ifndef _CHAT_WINDOW_H
#define ChatWindow_H_ #define _CHAT_WINDOW_H
#include <Window.h> #include <Window.h>
#include <TextView.h> #include <TextView.h>
#include "Observer.h" #include "Observer.h"
#include "CayaConstants.h" #include "CayaConstants.h"
class ContactLinker; class ContactLinker;
class CayaRenderView; class CayaRenderView;
class ChatWindow: public BWindow , public Observer class ChatWindow: public BWindow, public Observer {
{ public:
ChatWindow(ContactLinker* cl);
public: virtual void MessageReceived(BMessage* message);
ChatWindow(ContactLinker* cl); virtual bool QuitRequested();
virtual void MessageReceived(BMessage* message);
void ImMessage(BMessage *msg);
virtual bool QuitRequested();
void ObserveString(int32 what, BString str);
void ObservePointer(int32 what, void* ptr);
void ObserveInteger(int32 what, int32 val);
void AppendStatus(CayaStatus status);
private: void ImMessage(BMessage* msg);
BTextView* fSendView; void ObserveString(int32 what, BString str);
void ObservePointer(int32 what, void* ptr);
void ObserveInteger(int32 what, int32 val);
void AppendStatus(CayaStatus status);
private:
BTextView* fSendView;
ContactLinker* fContactLinker; ContactLinker* fContactLinker;
CayaRenderView *fReceiveView; CayaRenderView* fReceiveView;
}; };
#endif #endif // _CHAT_WINDOW_H
//--

View File

@ -17,7 +17,7 @@
EditingFilter::EditingFilter(BTextView* view) EditingFilter::EditingFilter(BTextView* view)
: :
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN, NULL), BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN, NULL),
_view(view) fView(view)
{ {
} }
@ -36,10 +36,10 @@ EditingFilter::Filter(BMessage* message, BHandler** target)
// If the Alt key jives with the command_enter status // If the Alt key jives with the command_enter status
if ((modifiers & B_COMMAND_KEY) != 0 && byte == B_ENTER) { if ((modifiers & B_COMMAND_KEY) != 0 && byte == B_ENTER) {
_view->Insert("\n"); fView->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(CAYA_CHAT); fView->Window()->PostMessage(CAYA_CHAT);
return B_SKIP_MESSAGE; return B_SKIP_MESSAGE;
} }

View File

@ -2,20 +2,20 @@
* Copyright 2009, Andrea Anzani. All rights reserved. * Copyright 2009, Andrea Anzani. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef EDITING_FILTER_H #ifndef _EDITING_FILTER_H
#define EDITING_FILTER_H #define _EDITING_FILTER_H
#include <MessageFilter.h> #include <MessageFilter.h>
#include <interface/TextView.h> #include <TextView.h>
class EditingFilter : public BMessageFilter { class EditingFilter : public BMessageFilter {
public: public:
EditingFilter(BTextView *view); EditingFilter(BTextView* view);
virtual filter_result Filter(BMessage *message, BHandler **target); virtual filter_result Filter(BMessage* message, BHandler** target);
private: private:
BTextView *_view; BTextView* fView;
}; };
#endif
#endif // _EDITING_FILTER_H

View File

@ -13,7 +13,7 @@
#include <Debug.h> #include <Debug.h>
#include <TranslationUtils.h> #include <TranslationUtils.h>
ImageCache *ImageCache::m_instance = NULL; ImageCache* ImageCache::fInstance = NULL;
ImageCache::ImageCache() ImageCache::ImageCache()
@ -23,8 +23,8 @@ ImageCache::ImageCache()
ImageCache::~ImageCache() ImageCache::~ImageCache()
{ {
while (m_bitmaps.CountItems()) { while (fBitmaps.CountItems()) {
BBitmap* bit = m_bitmaps.ValueFor(0); BBitmap* bit = fBitmaps.ValueFor(0);
delete bit; delete bit;
} }
} }
@ -33,20 +33,21 @@ ImageCache::~ImageCache()
BBitmap* BBitmap*
ImageCache::GetImage(BString which, BString name) ImageCache::GetImage(BString which, BString name)
{ {
if (m_instance == NULL) if (fInstance == NULL)
m_instance = new ImageCache(); fInstance = new ImageCache();
// Loads the bitmap if found // Loads the bitmap if found
bool found; bool found;
BBitmap* bitmap = m_instance->m_bitmaps.ValueFor(name, &found); BBitmap* bitmap = fInstance->fBitmaps.ValueFor(name, &found);
if (!found) { if (!found) {
bitmap = LoadImage(which.String(), name.String()); bitmap = LoadImage(which.String(), name.String());
if (bitmap) if (bitmap)
m_instance->m_bitmaps.AddItem(name, bitmap); fInstance->fBitmaps.AddItem(name, bitmap);
return bitmap; return bitmap;
} else } else
return bitmap; return bitmap;
return NULL; return NULL;
} }
@ -54,22 +55,22 @@ ImageCache::GetImage(BString which, BString name)
void void
ImageCache::AddImage(BString name, BBitmap* which) ImageCache::AddImage(BString name, BBitmap* which)
{ {
if (m_instance == NULL) if (fInstance == NULL)
m_instance = new ImageCache(); fInstance = new ImageCache();
m_instance->m_bitmaps.AddItem(name, which); fInstance->fBitmaps.AddItem(name, which);
} }
void void
ImageCache::DeleteImage(BString name) ImageCache::DeleteImage(BString name)
{ {
if (m_instance == NULL) if (fInstance == NULL)
m_instance = new ImageCache(); fInstance = new ImageCache();
BBitmap* bitmap = m_instance->m_bitmaps.ValueFor(name); BBitmap* bitmap = fInstance->fBitmaps.ValueFor(name);
if (bitmap){ if (bitmap) {
m_instance->m_bitmaps.RemoveItemFor(name); fInstance->fBitmaps.RemoveItemFor(name);
delete bitmap; delete bitmap;
} }
} }
@ -78,9 +79,9 @@ ImageCache::DeleteImage(BString name)
void void
ImageCache::Release() ImageCache::Release()
{ {
if (m_instance != NULL) { if (fInstance != NULL) {
delete m_instance; delete fInstance;
m_instance = NULL; fInstance = NULL;
} }
} }
@ -93,6 +94,6 @@ ImageCache::LoadImage(const char* fullName, const char* shortName)
bitmap = BTranslationUtils::GetBitmap('PNG ', shortName); bitmap = BTranslationUtils::GetBitmap('PNG ', shortName);
if (!bitmap) if (!bitmap)
printf("ImageCache: Can't load bitmap! %s\n",fullName); printf("ImageCache: Can't load bitmap! %s\n", fullName);
return bitmap; return bitmap;
} }

View File

@ -2,56 +2,40 @@
* Copyright 2009, Andrea Anzani. All rights reserved. * Copyright 2009, Andrea Anzani. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef ImageCache_H #ifndef _IMAGE_CACHE_H
#define ImageCache_H #define _IMAGE_CACHE_H
/**
* ImageCache.
* @author Andrea Anzani.
*/
class BBitmap;
#include <SupportDefs.h> #include <SupportDefs.h>
#include <String.h> #include <String.h>
#include <libsupport/KeyMap.h> #include <libsupport/KeyMap.h>
class ImageCache class BBitmap;
{
protected: // Constructor/Destructor class ImageCache {
public:
/* Returns the image corresponding to the which constant */
static BBitmap* GetImage(BString fullPath,
BString symbolicName);
static void AddImage(BString name, BBitmap* which);
static void DeleteImage(BString name);
/* Frees the singleton instance of the cache, must be
* called when the application quits.
*/
static void Release();
protected:
ImageCache(); ImageCache();
~ImageCache(); ~ImageCache();
public: // Operations private:
static BBitmap* LoadImage(const char* resourceName,
/** Returns the image corresponding to the which constant */ const char*);
static BBitmap * GetImage( BString fullPath , BString symbolicName);
static void AddImage(BString name,BBitmap* which);
static void DeleteImage(BString name);
/** Frees the singleton instance of the cache;
Call this when app quits
*/
static void Release();
private:
static BBitmap * LoadImage( const char *resourceName,const char *);
// Class Data
static ImageCache * m_instance;
private: // Instance Data
KeyMap<BString,BBitmap*> m_bitmaps;
static ImageCache* fInstance;
KeyMap<BString, BBitmap*> fBitmaps;
}; };
#endif /* __C_ImageCache_H__ */ #endif // _IMAGE_CACHE_H

View File

@ -22,7 +22,7 @@ typedef List<CayaProtocolAddOn*> ProtocolAddOns;
typedef KeyMap<BString, CayaProtocolAddOn*> AddOnMap; typedef KeyMap<BString, CayaProtocolAddOn*> AddOnMap;
typedef KeyMap<bigtime_t, CayaProtocol*> ProtocolMap; typedef KeyMap<bigtime_t, CayaProtocol*> ProtocolMap;
class ProtocolManager { class ProtocolManager {
public: public:
void Init(BDirectory dir, BHandler* target); void Init(BDirectory dir, BHandler* target);
@ -35,12 +35,13 @@ public:
CayaProtocolAddOn* ProtocolAddOn(const char* signature); CayaProtocolAddOn* ProtocolAddOn(const char* signature);
void AddAccount(CayaProtocolAddOn* addOn, void AddAccount(CayaProtocolAddOn* addOn,
const char* account, const char* account,
BHandler* target); BHandler* target);
private: private:
ProtocolManager(); ProtocolManager();
void _GetAccounts(CayaProtocolAddOn* addOn, BHandler* target); void _GetAccounts(CayaProtocolAddOn* addOn,
BHandler* target);
AddOnMap fAddOnMap; AddOnMap fAddOnMap;
ProtocolMap fProtocolMap; ProtocolMap fProtocolMap;

View File

@ -136,7 +136,7 @@ Server::Filter(BMessage* message, BHandler **target)
BString id = message->FindString("id"); BString id = message->FindString("id");
if (id.Length() > 0) { 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)
item->HideWindow(); item->HideWindow();
@ -244,7 +244,7 @@ Server::ImMessage(BMessage* msg)
// BPath fullPath(&ref); // BPath fullPath(&ref);
// BBitmap* bitmap = ImageCache::GetImage( // BBitmap* bitmap = ImageCache::GetImage(
// BString(fullPath.Path()), BString(fullPath.Path())); // BString(fullPath.Path()), BString(fullPath.Path()));
BBitmap *bitmap = BTranslationUtils::GetBitmap(&ref); BBitmap* bitmap = BTranslationUtils::GetBitmap(&ref);
linker->SetNotifyAvatarBitmap(bitmap); linker->SetNotifyAvatarBitmap(bitmap);
} else } else
linker->SetNotifyAvatarBitmap(NULL); linker->SetNotifyAvatarBitmap(NULL);

View File

@ -30,22 +30,19 @@ public:
void Quit(); void Quit();
void AddProtocolLooper(bigtime_t instanceId, CayaProtocol* cayap); void AddProtocolLooper(bigtime_t instanceId,
CayaProtocol* cayap);
void RemoveProtocolLooper(bigtime_t instanceId); void RemoveProtocolLooper(bigtime_t instanceId);
void LoginAll(); void LoginAll();
#if 0
void UpdateSettings(BMessage settings);
#endif
void SendProtocolMessage(BMessage* msg); void SendProtocolMessage(BMessage* msg);
void SendAllProtocolMessage(BMessage* msg); void SendAllProtocolMessage(BMessage* msg);
RosterMap RosterItems() const; RosterMap RosterItems() const;
RosterItem* RosterItemForId(BString id); RosterItem* RosterItemForId(BString id);
//TODO: there should be a contact for each account. // TODO: there should be a contact for each account.
ContactLinker* GetOwnContact(); ContactLinker* GetOwnContact();
private: private:

View File

@ -20,14 +20,15 @@
#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, ProtocolSettings* settings, 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 | :
B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), BWindow(BRect(0, 0, 1, 1), title, B_MODAL_WINDOW, B_NOT_RESIZABLE
| B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
fSettings(settings), fSettings(settings),
fAccount(account), fAccount(account),
fTarget(NULL) fTarget(NULL)

View File

@ -18,8 +18,9 @@ const uint32 kAccountRenamed = 'acrd';
class AccountDialog : public BWindow { class AccountDialog : public BWindow {
public: public:
AccountDialog(const char* title, ProtocolSettings* settings, AccountDialog(const char* title,
const char* account = NULL); ProtocolSettings* settings,
const char* account = NULL);
void SetTarget(BHandler* target); void SetTarget(BHandler* target);

View File

@ -12,8 +12,10 @@
#include "ProtocolSettings.h" #include "ProtocolSettings.h"
AccountListItem::AccountListItem(ProtocolSettings* settings, const char* account) AccountListItem::AccountListItem(ProtocolSettings* settings,
: BStringItem(account), const char* account)
:
BStringItem(account),
fSettings(settings), fSettings(settings),
fAccount(account), fAccount(account),
fBaselineOffset(0) fBaselineOffset(0)
@ -55,7 +57,7 @@ AccountListItem::DrawItem(BView* owner, BRect frame, bool complete)
rgb_color lowColor = owner->LowColor(); rgb_color lowColor = owner->LowColor();
// Draw selection // Draw selection
if (IsSelected()) { if (IsSelected()) {
rgb_color highlightColor = ui_color(B_CONTROL_HIGHLIGHT_COLOR); rgb_color highlightColor = ui_color(B_CONTROL_HIGHLIGHT_COLOR);
owner->SetLowColor(highlightColor); owner->SetLowColor(highlightColor);
@ -65,11 +67,11 @@ AccountListItem::DrawItem(BView* owner, BRect frame, bool complete)
// Draw account name // Draw account name
rgb_color textColor = ui_color(B_CONTROL_TEXT_COLOR); rgb_color textColor = ui_color(B_CONTROL_TEXT_COLOR);
owner->MovePenTo(frame.left, frame.top + fBaselineOffset); owner->MovePenTo(frame.left, frame.top + fBaselineOffset);
if (!IsEnabled()) if (!IsEnabled())
owner->SetHighColor(tint_color(textColor, B_LIGHTEN_2_TINT)); owner->SetHighColor(tint_color(textColor, B_LIGHTEN_2_TINT));
else else
owner->SetHighColor(textColor); owner->SetHighColor(textColor);
owner->DrawString(Text()); owner->DrawString(Text());
owner->SetHighColor(highColor); owner->SetHighColor(highColor);

View File

@ -164,9 +164,6 @@ RosterListView::Draw(BRect updateRect)
} }
// #pragama mark -
void void
RosterListView::Sort() RosterListView::Sort()
{ {

View File

@ -17,13 +17,14 @@
#include "CayaUtils.h" #include "CayaUtils.h"
#include "StatusMenuItem.h" #include "StatusMenuItem.h"
const float kSize = 16; const float kSize = 16;
const float kCircle = 12; const float kCircle = 12;
StatusMenuItem::StatusMenuItem(const char* label, CayaStatus status, StatusMenuItem::StatusMenuItem(const char* label, CayaStatus status,
bool custom, char shortcut, uint32 modifiers) bool custom, char shortcut, uint32 modifiers)
: BitmapMenuItem(label, NULL, NULL, shortcut, modifiers), :
BitmapMenuItem(label, NULL, NULL, shortcut, modifiers),
fStatus(status), fStatus(status),
fCustom(custom) fCustom(custom)
{ {