Cleaning up the AIM code base and adding the right icon from IM Kit.
This commit is contained in:
parent
e524826f03
commit
c599c12c7f
|
@ -1,3 +1,8 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010, Alexander Botero-Lowry. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -13,7 +18,6 @@ CayaProtocolMessengerInterface *gServerMsgr;
|
||||||
|
|
||||||
AIMProtocol::AIMProtocol()
|
AIMProtocol::AIMProtocol()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,11 +30,12 @@ AIMProtocol::~AIMProtocol()
|
||||||
status_t
|
status_t
|
||||||
AIMProtocol::Init(CayaProtocolMessengerInterface* msgr)
|
AIMProtocol::Init(CayaProtocolMessengerInterface* msgr)
|
||||||
{
|
{
|
||||||
printf("init\n");
|
|
||||||
gServerMsgr = msgr;
|
gServerMsgr = msgr;
|
||||||
|
|
||||||
fIMCommHandle = imcomm_create_handle();
|
fIMCommHandle = imcomm_create_handle();
|
||||||
fOnline = false;
|
fOnline = false;
|
||||||
|
|
||||||
|
// Register callbacks
|
||||||
imcomm_register_callback(fIMCommHandle, IMCOMM_IM_INCOMING, (void (*)())GotMessage);
|
imcomm_register_callback(fIMCommHandle, IMCOMM_IM_INCOMING, (void (*)())GotMessage);
|
||||||
imcomm_register_callback(fIMCommHandle, IMCOMM_IM_SIGNON, (void (*)())BuddyOnline);
|
imcomm_register_callback(fIMCommHandle, IMCOMM_IM_SIGNON, (void (*)())BuddyOnline);
|
||||||
imcomm_register_callback(fIMCommHandle, IMCOMM_IM_SIGNOFF, (void (*)())BuddyOffline);
|
imcomm_register_callback(fIMCommHandle, IMCOMM_IM_SIGNOFF, (void (*)())BuddyOffline);
|
||||||
|
@ -40,7 +45,7 @@ AIMProtocol::Init(CayaProtocolMessengerInterface* msgr)
|
||||||
imcomm_register_callback(fIMCommHandle, IMCOMM_IM_IDLEINFO, (void (*)())BuddyIdle);
|
imcomm_register_callback(fIMCommHandle, IMCOMM_IM_IDLEINFO, (void (*)())BuddyIdle);
|
||||||
imcomm_register_callback(fIMCommHandle, IMCOMM_IM_PROFILE, (void (*)())BuddyProfile);
|
imcomm_register_callback(fIMCommHandle, IMCOMM_IM_PROFILE, (void (*)())BuddyProfile);
|
||||||
|
|
||||||
// XXX missing IMCOMM_ERROR, IMCOMM_FORMATTED_SN, IMCOMM_HANDLE_DELETED
|
// TODO: Missing IMCOMM_ERROR, IMCOMM_FORMATTED_SN, IMCOMM_HANDLE_DELETED
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
@ -57,47 +62,36 @@ AIMProtocol::Shutdown()
|
||||||
status_t
|
status_t
|
||||||
AIMProtocol::Process(BMessage* msg)
|
AIMProtocol::Process(BMessage* msg)
|
||||||
{
|
{
|
||||||
msg->PrintToStream();
|
|
||||||
|
|
||||||
switch (msg->what) {
|
switch (msg->what) {
|
||||||
case IM_MESSAGE:
|
case IM_MESSAGE: {
|
||||||
{
|
|
||||||
int32 im_what = 0;
|
int32 im_what = 0;
|
||||||
|
|
||||||
msg->FindInt32("im_what", &im_what);
|
msg->FindInt32("im_what", &im_what);
|
||||||
|
|
||||||
switch (im_what) {
|
switch (im_what) {
|
||||||
case IM_SET_STATUS:
|
case IM_SET_STATUS: {
|
||||||
{
|
|
||||||
int32 status = msg->FindInt32("status");
|
int32 status = msg->FindInt32("status");
|
||||||
|
|
||||||
BString status_msg("");
|
BString status_msg("");
|
||||||
msg->FindString("message", &status_msg);
|
msg->FindString("message", &status_msg);
|
||||||
char* smsg = strdup(status_msg.String());
|
char* smsg = strdup(status_msg.String());
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case CAYA_ONLINE:
|
case CAYA_ONLINE:
|
||||||
{
|
if (!fOnline)
|
||||||
if (!fOnline) {
|
|
||||||
A_LogOn();
|
A_LogOn();
|
||||||
} else {
|
else
|
||||||
imcomm_set_unaway(fIMCommHandle);
|
imcomm_set_unaway(fIMCommHandle);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case CAYA_AWAY:
|
case CAYA_AWAY:
|
||||||
imcomm_set_away(fIMCommHandle,
|
imcomm_set_away(fIMCommHandle, smsg);
|
||||||
smsg);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CAYA_EXTENDED_AWAY:
|
case CAYA_EXTENDED_AWAY:
|
||||||
imcomm_set_away(fIMCommHandle,
|
imcomm_set_away(fIMCommHandle, smsg);
|
||||||
smsg);
|
|
||||||
|
|
||||||
//UnsupportedOperation(); ?
|
//UnsupportedOperation(); ?
|
||||||
break;
|
break;
|
||||||
case CAYA_DO_NOT_DISTURB:
|
case CAYA_DO_NOT_DISTURB:
|
||||||
imcomm_set_away(fIMCommHandle,
|
imcomm_set_away(fIMCommHandle, smsg);
|
||||||
smsg);
|
|
||||||
//UnsupportedOperation(); ?
|
//UnsupportedOperation(); ?
|
||||||
break;
|
break;
|
||||||
case CAYA_OFFLINE:
|
case CAYA_OFFLINE:
|
||||||
|
@ -113,25 +107,18 @@ AIMProtocol::Process(BMessage* msg)
|
||||||
msg.AddInt32("im_what", IM_STATUS_SET);
|
msg.AddInt32("im_what", IM_STATUS_SET);
|
||||||
msg.AddString("protocol", kProtocolName);
|
msg.AddString("protocol", kProtocolName);
|
||||||
msg.AddInt32("status", status);
|
msg.AddInt32("status", status);
|
||||||
|
|
||||||
gServerMsgr->SendMessage(&msg);
|
gServerMsgr->SendMessage(&msg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IM_SET_NICKNAME:
|
case IM_SET_NICKNAME:
|
||||||
{
|
|
||||||
UnsupportedOperation();
|
UnsupportedOperation();
|
||||||
break;
|
break;
|
||||||
}
|
case IM_SEND_MESSAGE: {
|
||||||
case IM_SEND_MESSAGE:
|
|
||||||
{
|
|
||||||
const char* buddy = msg->FindString("id");
|
const char* buddy = msg->FindString("id");
|
||||||
const char* sms = msg->FindString("message");
|
const char* sms = msg->FindString("message");
|
||||||
imcomm_im_send_message(fIMCommHandle, buddy,
|
imcomm_im_send_message(fIMCommHandle, buddy, sms, 0);
|
||||||
sms, 0);
|
|
||||||
|
|
||||||
// XXX send a message to let caya know
|
// XXX send a message to let caya know we did it
|
||||||
// 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", kProtocolName);
|
||||||
|
@ -141,57 +128,40 @@ AIMProtocol::Process(BMessage* msg)
|
||||||
gServerMsgr->SendMessage(&msg);
|
gServerMsgr->SendMessage(&msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IM_REGISTER_CONTACTS:
|
case IM_REGISTER_CONTACTS: {
|
||||||
{
|
|
||||||
const char* buddy = NULL;
|
const char* buddy = NULL;
|
||||||
char *buddy_copy;
|
char *buddy_copy;
|
||||||
|
|
||||||
for (int i = 0;
|
for (int32 i = 0; msg->FindString("id", i, &buddy) == B_OK; i++) {
|
||||||
msg->FindString("id", i, &buddy) == B_OK;
|
|
||||||
i++) {
|
|
||||||
buddy_copy = strdup(buddy);
|
buddy_copy = strdup(buddy);
|
||||||
imcomm_im_add_buddy(fIMCommHandle, buddy_copy);
|
imcomm_im_add_buddy(fIMCommHandle, buddy_copy);
|
||||||
free(buddy_copy);
|
free(buddy_copy);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IM_UNREGISTER_CONTACTS:
|
case IM_UNREGISTER_CONTACTS: {
|
||||||
{
|
|
||||||
const char* buddy = NULL;
|
const char* buddy = NULL;
|
||||||
|
|
||||||
for (int i = 0;
|
for (int32 i = 0; msg->FindString("id", i, &buddy) == B_OK; i++)
|
||||||
msg->FindString("id", i, &buddy) == B_OK;
|
|
||||||
i++) {
|
|
||||||
imcomm_im_remove_buddy(fIMCommHandle, buddy);
|
imcomm_im_remove_buddy(fIMCommHandle, buddy);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IM_USER_STARTED_TYPING:
|
case IM_USER_STARTED_TYPING:
|
||||||
{
|
|
||||||
//UnsupportedOperation();
|
//UnsupportedOperation();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case IM_USER_STOPPED_TYPING:
|
case IM_USER_STOPPED_TYPING:
|
||||||
{
|
|
||||||
//UnsupportedOperation();
|
//UnsupportedOperation();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case IM_GET_CONTACT_INFO:
|
case IM_GET_CONTACT_INFO:
|
||||||
UnsupportedOperation();
|
UnsupportedOperation();
|
||||||
break;
|
break;
|
||||||
case IM_SEND_AUTH_ACK:
|
case IM_SEND_AUTH_ACK:
|
||||||
{
|
|
||||||
UnsupportedOperation();
|
UnsupportedOperation();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case IM_SPECIAL_TO_PROTOCOL:
|
case IM_SPECIAL_TO_PROTOCOL:
|
||||||
UnsupportedOperation();
|
UnsupportedOperation();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
msg->PrintToStream();
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -206,10 +176,11 @@ AIMProtocol::Process(BMessage* msg)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AIMProtocol::UnsupportedOperation() {
|
AIMProtocol::UnsupportedOperation()
|
||||||
printf("noop\n");
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
AIMProtocol::GetSignature()
|
AIMProtocol::GetSignature()
|
||||||
{
|
{
|
||||||
|
@ -232,11 +203,10 @@ AIMProtocol::UpdateSettings(BMessage& msg)
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
if ((username == NULL) || (password == NULL)) {
|
if ((username == NULL) || (password == NULL)) {
|
||||||
//LOG( kProtocolName, liHigh, "Invalid settings!");
|
|
||||||
printf("Invalid settings");
|
printf("Invalid settings");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -246,6 +216,7 @@ AIMProtocol::UpdateSettings(BMessage& msg)
|
||||||
fPassword = password;
|
fPassword = password;
|
||||||
// XXX kill the handle and sign back in?
|
// XXX kill the handle and sign back in?
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,9 +232,6 @@ status_t
|
||||||
AIMProtocol::A_LogOn()
|
AIMProtocol::A_LogOn()
|
||||||
{
|
{
|
||||||
int ret = imcomm_im_signon(fIMCommHandle, fUsername, fPassword);
|
int ret = imcomm_im_signon(fIMCommHandle, fUsername, fPassword);
|
||||||
|
|
||||||
printf("ret: %d\n", ret);
|
|
||||||
|
|
||||||
if (ret == IMCOMM_RET_OK) {
|
if (ret == IMCOMM_RET_OK) {
|
||||||
fIMCommThread = spawn_thread(WaitForData, "imcomm receiver",
|
fIMCommThread = spawn_thread(WaitForData, "imcomm receiver",
|
||||||
B_LOW_PRIORITY, this);
|
B_LOW_PRIORITY, this);
|
||||||
|
@ -273,6 +241,7 @@ AIMProtocol::A_LogOn()
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,10 +255,11 @@ AIMProtocol::LogOff()
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
AIMProtocol::WaitForData(void *aimProtocol) {
|
AIMProtocol::WaitForData(void* aimProtocol)
|
||||||
|
{
|
||||||
// XXX No need for aimProtocol since imcomm does its own callback thing
|
// XXX No need for aimProtocol since imcomm does its own callback thing
|
||||||
printf("wait\n");
|
|
||||||
fd_set readset;
|
fd_set readset;
|
||||||
struct timeval tm;
|
struct timeval tm;
|
||||||
|
|
||||||
|
@ -299,7 +269,8 @@ AIMProtocol::WaitForData(void *aimProtocol) {
|
||||||
tm.tv_usec = 500000;
|
tm.tv_usec = 500000;
|
||||||
|
|
||||||
IMCOMM_RET ret = imcomm_select(1, &readset, NULL, NULL, &tm);
|
IMCOMM_RET ret = imcomm_select(1, &readset, NULL, NULL, &tm);
|
||||||
if (ret != IMCOMM_RET_OK && errno == EINTR) continue;
|
if (ret != IMCOMM_RET_OK && errno == EINTR)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -307,7 +278,8 @@ AIMProtocol::WaitForData(void *aimProtocol) {
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AIMProtocol::GotMessage(void *imcomm, char *who, int auto, char *recvmsg) {
|
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", kProtocolName);
|
||||||
|
@ -317,8 +289,10 @@ AIMProtocol::GotMessage(void *imcomm, char *who, int auto, char *recvmsg) {
|
||||||
gServerMsgr->SendMessage(&msg);
|
gServerMsgr->SendMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AIMProtocol::BuddyOnline(void *imcomm, char *who) {
|
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", kProtocolName);
|
||||||
|
@ -328,11 +302,12 @@ AIMProtocol::BuddyOnline(void *imcomm, char *who) {
|
||||||
gServerMsgr->SendMessage(&msg);
|
gServerMsgr->SendMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AIMProtocol::BuddyOffline(void *imcomm, char *who) {
|
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", kProtocolName);
|
||||||
msg.AddString("id", who);
|
msg.AddString("id", who);
|
||||||
msg.AddInt32("status", CAYA_OFFLINE);
|
msg.AddInt32("status", CAYA_OFFLINE);
|
||||||
|
@ -340,13 +315,17 @@ AIMProtocol::BuddyOffline(void *imcomm, char *who) {
|
||||||
gServerMsgr->SendMessage(&msg);
|
gServerMsgr->SendMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AIMProtocol::BuddyAway(void *imcomm, char *who) {
|
AIMProtocol::BuddyAway(void* imcomm, char* who)
|
||||||
|
{
|
||||||
imcomm_request_awaymsg(imcomm, who);
|
imcomm_request_awaymsg(imcomm, who);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AIMProtocol::BuddyBack(void *imcomm, char *who) {
|
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", kProtocolName);
|
||||||
|
@ -356,10 +335,11 @@ AIMProtocol::BuddyBack(void *imcomm, char *who) {
|
||||||
gServerMsgr->SendMessage(&msg);
|
gServerMsgr->SendMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AIMProtocol::BuddyAwayMsg(void *imcomm, char *who, char *awaymsg) {
|
|
||||||
BMessage msg(IM_MESSAGE);
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AIMProtocol::BuddyAwayMsg(void* imcomm, char* who, char* awaymsg)
|
||||||
|
{
|
||||||
|
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", kProtocolName);
|
||||||
msg.AddString("id", who);
|
msg.AddString("id", who);
|
||||||
|
@ -369,8 +349,10 @@ AIMProtocol::BuddyAwayMsg(void *imcomm, char *who, char *awaymsg) {
|
||||||
gServerMsgr->SendMessage(&msg);
|
gServerMsgr->SendMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AIMProtocol::BuddyIdle(void *imcomm, char *who, long idletime) {
|
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", kProtocolName);
|
||||||
|
@ -378,43 +360,35 @@ AIMProtocol::BuddyIdle(void *imcomm, char *who, long idletime) {
|
||||||
msg.AddInt32("status", CAYA_ONLINE);
|
msg.AddInt32("status", CAYA_ONLINE);
|
||||||
|
|
||||||
gServerMsgr->SendMessage(&msg);
|
gServerMsgr->SendMessage(&msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AIMProtocol::BuddyProfile(void *handle, char *who, char *profile) {
|
AIMProtocol::BuddyProfile(void* handle, char* who, char* profile)
|
||||||
|
{
|
||||||
// XXX vcard is probably an issue
|
// XXX vcard is probably an issue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
AIMProtocol::strip_html(const char* message)
|
AIMProtocol::strip_html(const char* message)
|
||||||
{
|
{
|
||||||
char* temp;
|
char* temp;
|
||||||
int x, xnot, y, count, inhtml;
|
uint32 x, xnot, y, count, inhtml;
|
||||||
size_t len = strlen(message);
|
size_t len = strlen(message);
|
||||||
|
|
||||||
temp = (char*)malloc(len + 1);
|
temp = (char*)malloc(len + 1);
|
||||||
for (x = 0, count = 0, inhtml = 0; x < len; x++) {
|
for (x = 0, count = 0, inhtml = 0; x < len; x++) {
|
||||||
if (message[x] == '<' && inhtml == 0) {
|
if (message[x] == '<' && inhtml == 0) {
|
||||||
if (x + 10 < len) {
|
if (x + 10 < len) {
|
||||||
|
// Convert links into [http://url] link text
|
||||||
/**
|
|
||||||
** Convert links into
|
|
||||||
** [http://url] link text
|
|
||||||
**/
|
|
||||||
|
|
||||||
if (strncasecmp(message + x, "<a href=\"", 9) == 0) {
|
if (strncasecmp(message + x, "<a href=\"", 9) == 0) {
|
||||||
xnot = x + 9;
|
xnot = x + 9;
|
||||||
|
|
||||||
for (y = xnot; y < len; y++) {
|
for (y = xnot; y < len; y++) {
|
||||||
if (message[y] == '\"') {
|
if (message[y] == '\"') {
|
||||||
/*
|
// We don't have to worry about the buffer size,
|
||||||
* we don't have to
|
// because it's guaranteed to be bigger
|
||||||
* worry about the
|
|
||||||
* buffer size,
|
|
||||||
* because it's
|
|
||||||
* guaranteed to be
|
|
||||||
* bigger
|
|
||||||
*/
|
|
||||||
memcpy(temp + count, "[", 1);
|
memcpy(temp + count, "[", 1);
|
||||||
memcpy(temp + count + 1, message + xnot,
|
memcpy(temp + count + 1, message + xnot,
|
||||||
y - xnot);
|
y - xnot);
|
||||||
|
@ -426,6 +400,7 @@ AIMProtocol::strip_html(const char *message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x + 3 < len) {
|
if (x + 3 < len) {
|
||||||
if (strncasecmp(message + x, "<br>", 4) == 0) {
|
if (strncasecmp(message + x, "<br>", 4) == 0) {
|
||||||
temp[count] = '\n';
|
temp[count] = '\n';
|
||||||
|
@ -434,15 +409,18 @@ AIMProtocol::strip_html(const char *message)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inhtml = 1;
|
inhtml = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inhtml) {
|
if (inhtml) {
|
||||||
if (message[x] == '>')
|
if (message[x] == '>')
|
||||||
inhtml = 0;
|
inhtml = 0;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message[x] == '&') {
|
if (message[x] == '&') {
|
||||||
if (x + 4 < len) {
|
if (x + 4 < len) {
|
||||||
if (strncmp(message + x, "&", 5) == 0) {
|
if (strncmp(message + x, "&", 5) == 0) {
|
||||||
|
@ -452,6 +430,7 @@ AIMProtocol::strip_html(const char *message)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x + 5 < len) {
|
if (x + 5 < len) {
|
||||||
if (strncmp(message + x, """, 6) == 0) {
|
if (strncmp(message + x, """, 6) == 0) {
|
||||||
temp[count] = '\"';
|
temp[count] = '\"';
|
||||||
|
@ -459,6 +438,7 @@ AIMProtocol::strip_html(const char *message)
|
||||||
x += 5;
|
x += 5;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(message + x, " ", 6) == 0) {
|
if (strncmp(message + x, " ", 6) == 0) {
|
||||||
temp[count] = ' ';
|
temp[count] = ' ';
|
||||||
count++;
|
count++;
|
||||||
|
@ -466,6 +446,7 @@ AIMProtocol::strip_html(const char *message)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x + 3 < len) {
|
if (x + 3 < len) {
|
||||||
if (strncmp(message + x, "<", 4) == 0) {
|
if (strncmp(message + x, "<", 4) == 0) {
|
||||||
temp[count] = '<';
|
temp[count] = '<';
|
||||||
|
@ -474,6 +455,7 @@ AIMProtocol::strip_html(const char *message)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x + 3 < len) {
|
if (x + 3 < len) {
|
||||||
if (strncmp(message + x, ">", 4) == 0) {
|
if (strncmp(message + x, ">", 4) == 0) {
|
||||||
temp[count] = '>';
|
temp[count] = '>';
|
||||||
|
@ -483,6 +465,7 @@ AIMProtocol::strip_html(const char *message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message[x] == '\n' || message[x] == '\r')
|
if (message[x] == '\n' || message[x] == '\r')
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2004-2009, IM Kit Team. All rights reserved.
|
* Copyright 2010, Alexander Botero-Lowry. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef IMKIT_AIM_H
|
#ifndef _AIM_H
|
||||||
#define IMKIT_AIM_H
|
#define _AIM_H
|
||||||
|
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
|
@ -19,9 +19,11 @@ public:
|
||||||
AIMProtocol();
|
AIMProtocol();
|
||||||
virtual ~AIMProtocol();
|
virtual ~AIMProtocol();
|
||||||
|
|
||||||
virtual status_t Init( CayaProtocolMessengerInterface* );
|
virtual status_t Init(CayaProtocolMessengerInterface* messenger);
|
||||||
|
|
||||||
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* GetSignature();
|
||||||
virtual const char* GetFriendlySignature();
|
virtual const char* GetFriendlySignature();
|
||||||
virtual status_t UpdateSettings(BMessage&);
|
virtual status_t UpdateSettings(BMessage&);
|
||||||
|
@ -38,21 +40,19 @@ public:
|
||||||
static void BuddyIdle(void*, char*, long);
|
static void BuddyIdle(void*, char*, long);
|
||||||
static void BuddyProfile(void*, char*, char*);
|
static void BuddyProfile(void*, char*, char*);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BString fUsername;
|
|
||||||
BString fPassword;
|
|
||||||
bool fOnline;
|
|
||||||
thread_id fIMCommThread;
|
|
||||||
|
|
||||||
void * fIMCommHandle;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
status_t A_LogOn();
|
status_t A_LogOn();
|
||||||
status_t LogOff();
|
status_t LogOff();
|
||||||
void UnsupportedOperation();
|
void UnsupportedOperation();
|
||||||
|
|
||||||
static char* strip_html(const char* message);
|
static char* strip_html(const char* message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BString fUsername;
|
||||||
|
BString fPassword;
|
||||||
|
bool fOnline;
|
||||||
|
thread_id fIMCommThread;
|
||||||
|
void* fIMCommHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IMKIT_AIM_H
|
#endif // _AIM_H
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
resource app_version {
|
resource app_version {
|
||||||
major = 0,
|
major = 0,
|
||||||
middle = 0,
|
middle = 0,
|
||||||
minor = 0,
|
minor = 1,
|
||||||
|
|
||||||
variety = B_APPV_ALPHA,
|
variety = B_APPV_ALPHA,
|
||||||
internal = 0,
|
internal = 0,
|
||||||
|
@ -12,23 +12,13 @@ resource app_version {
|
||||||
};
|
};
|
||||||
|
|
||||||
resource vector_icon {
|
resource vector_icon {
|
||||||
$"6E636966080501040046020106023E40000000000000003D4000494000470000"
|
$"6E636966050501020106023E40000000000000003E4000490000490000FFFFCC"
|
||||||
$"7EFFFFFFFFE5E1DA02000602000000BBC0004000000000009220244AF0000000"
|
$"007FFFFF00020106023B80000000000000003B80004A6000460000FFFFCC007C"
|
||||||
$"33CCFC3366FF02000602000000BA000040000000000092202448800000336699"
|
$"FFFF00020112023AD09E3A55D0BD34993DDD2B49C9E2492C1BFFFF007AFFD102"
|
||||||
$"FF6699CC02000602000000B9000040000000000092202448E00000CC0000FFFF"
|
$"0112023C80000000000000003C80004A0000420000FFFF007AFFD102060CFFBB"
|
||||||
$"000002000602000000BA000040000000000092202448800000FF9900FFFBFF00"
|
$"B348464846524A5C5A56505C5A525E525E505A405048503A56265C305C265C24"
|
||||||
$"02000602000000BA000040000000000092202448800000006600FF00CC000A02"
|
$"5238443850383A4034483A483A4C3C5C5C425C425844484402044A22C18022C5"
|
||||||
$"06C22622C7562239222E342E2B2E3D4146364441483C50404C3C504A444A4E55"
|
$"F722542C54B58C54BA034A36C5F736C18036402C40BA0340B58C060A00010010"
|
||||||
$"44CBB634CBB83E5E2A0206C22622C7562239222E342E2B2E3D4146364441483C"
|
$"01178400040A0001011001178400040A010100000A020101000A030100100115"
|
||||||
$"50404C3C504C464A505744CBB634CBB83E5E2A02024C265928532A583B59335D"
|
$"7F00040A0401011001157F0004"
|
||||||
$"350610CAFFFEAF375335543B3B5A3B5A395D325D355D2C5D274F275627483241"
|
|
||||||
$"2C413541BDA7C2A83942BDA7C2A8394A3F463F463C40324036402A40234F2346"
|
|
||||||
$"2358325E2A5E395EBF5C5A3F5CBF5C5A3F544053080234313C310404FE372C37"
|
|
||||||
$"393739373A393B383B3A3B3B393B3A3B390406FE0B4536403640363F363E383E"
|
|
||||||
$"373E383E393E393E3A403B3F3B413B453A0405FE03453C453445344533433244"
|
|
||||||
$"324332403240323F323E343E333E3408024D2C4D3C0803553C4F3655300D0A00"
|
|
||||||
$"01001001178400040A020101000A010102000A0101032021210A010204053021"
|
|
||||||
$"2101178200040A0102070630212101178200040A010108301D2101178200040A"
|
|
||||||
$"0102090830212101178200040A030103000A040204051001178200040A050207"
|
|
||||||
$"061001178200040A060108301C2001178200040A07020908100117820004"
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010, Alexander Botero-Lowry. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "AIM.h"
|
#include "AIM.h"
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) CayaProtocol *main_protocol();
|
extern "C" __declspec(dllexport) CayaProtocol *main_protocol();
|
||||||
|
|
||||||
CayaProtocol *main_protocol()
|
CayaProtocol *main_protocol()
|
||||||
{
|
{
|
||||||
return (CayaProtocol *)(new AIMProtocol());
|
return (CayaProtocol*)new AIMProtocol();
|
||||||
}
|
}
|
||||||
|
|
Ŝarĝante…
Reference in New Issue