コード例 #1
0
ファイル: switchboard.c プロジェクト: VoxOx/VoxOx
/**************************************************************************
 * Connect stuff
 **************************************************************************/
static void
connect_cb(MsnServConn *servconn)
{
	MsnSwitchBoard *swboard;
	MsnCmdProc *cmdproc;
	GaimAccount *account;

	cmdproc = servconn->cmdproc;
	g_return_if_fail(cmdproc != NULL);

	account = cmdproc->session->account;
	swboard = cmdproc->data;
	g_return_if_fail(swboard != NULL);

	if (msn_switchboard_is_invited(swboard))
	{
		swboard->empty = FALSE;

		msn_cmdproc_send(cmdproc, "ANS", "%s %s %s",
						 gaim_account_get_username(account),
						 swboard->auth_key, swboard->session_id);
	}
	else
	{
		msn_cmdproc_send(cmdproc, "USR", "%s %s",
						 gaim_account_get_username(account),
						 swboard->auth_key);
	}
}
コード例 #2
0
static void
sending_im_msg_cb(GaimAccount *account, char *recipient, char **buffer, void *data)
{
	gaim_debug_misc("signals test", "sending-im-msg (%s, %s, %s)\n",
					gaim_account_get_username(account), recipient, *buffer);

}
コード例 #3
0
ファイル: log.c プロジェクト: BackupTheBerlios/koopa-svn
static char *
gaim_log_get_log_dir(GaimLogType type, const char *name, GaimAccount *account)
{
	GaimPlugin *prpl;
	GaimPluginProtocolInfo *prpl_info;
	const char *prpl_name;
	char *acct_name;
	const char *target;
	char *dir;

	prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
	if (!prpl)
		return NULL;
	prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
	prpl_name = prpl_info->list_icon(account, NULL);

	acct_name = g_strdup(gaim_escape_filename(gaim_normalize(account,
				gaim_account_get_username(account))));

	if (type == GAIM_LOG_CHAT) {
		char *temp = g_strdup_printf("%s.chat", gaim_normalize(account, name));
		target = gaim_escape_filename(temp);
		g_free(temp);
	} else if(type == GAIM_LOG_SYSTEM) {
		target = ".system";
	} else {
		target = gaim_escape_filename(gaim_normalize(account, name));
	}

	dir = g_build_filename(gaim_user_dir(), "logs", prpl_name, acct_name, target, NULL);

	g_free(acct_name);

	return dir;
}
コード例 #4
0
ファイル: gaym.c プロジェクト: BackupTheBerlios/qrc-svn
static void gaym_login_with_chat_key(GaimAccount * account)
{
    GaimConnection *gc;
    struct gaym_conn *gaym;
    char *buf;
    const char *username = gaim_account_get_username(account);
    int err;

    gc = gaim_account_get_connection(account);
    gaym = gc->proto_data;

    buf = g_strdup_printf(_("Signon: %s"), username);
    gaim_connection_update_progress(gc, buf, 5, 6);
    g_free(buf);
    gaim_debug_misc("gaym", "Trying login to %s\n", gaym->server);
    err = gaim_proxy_connect(account, gaym->server,
                             gaim_account_get_int(account, "port",
                                                  IRC_DEFAULT_PORT),
                             gaym_login_cb, gc);
    if (err || !account->gc) {
        gaim_connection_error(gc, _("Couldn't create socket"));
        gaim_debug_misc("gaym", "err: %d, account->gc: %x\n", err,
                        account->gc);
        return;
    }

}
コード例 #5
0
ファイル: notification.c プロジェクト: VoxOx/VoxOx
static void
ver_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
{
	MsnSession *session;
	GaimAccount *account;
	gboolean protocol_supported = FALSE;
	char proto_str[8];
	size_t i;

	session = cmdproc->session;
	account = session->account;

	g_snprintf(proto_str, sizeof(proto_str), "MSNP%d", session->protocol_ver);

	for (i = 1; i < cmd->param_count; i++)
	{
		if (!strcmp(cmd->params[i], proto_str))
		{
			protocol_supported = TRUE;
			break;
		}
	}

	if (!protocol_supported)
	{
		msn_session_set_error(session, MSN_ERROR_UNSUPPORTED_PROTOCOL,
							  NULL);
		return;
	}

	msn_cmdproc_send(cmdproc, "CVR",
					 "0x0409 winnt 5.1 i386 MSNMSGR 6.0.0602 MSMSGS %s",
					 gaim_account_get_username(account));
}
コード例 #6
0
static void
account_away_cb(GaimAccount *account, const char *state,
				const char *message, void *data)
{
	gaim_debug_misc("signals test", "account-away (%s, %s, %s)\n",
					gaim_account_get_username(account), state, message);
}
コード例 #7
0
static void
account_warned_cb(GaimAccount *account, const char *warner, int level,
				  void *data)
{
	gaim_debug_misc("signals test", "account-warned (%s, %s, %d)\n",
					gaim_account_get_username(account), warner, level);
}
コード例 #8
0
ファイル: dbus-useful.c プロジェクト: VoxOx/VoxOx
GaimAccount *
gaim_accounts_find_ext(const char *name, const char *protocol_id,
		       gboolean (*account_test)(const GaimAccount *account))
{
	GaimAccount *result = NULL;
	GList *l;
	char *who;

	if (name)
		who = g_strdup(gaim_normalize(NULL, name));
	else
		who = NULL;

	for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
		GaimAccount *account = (GaimAccount *)l->data;

		if (who && strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who))
			continue;

		if (protocol_id && strcmp(account->protocol_id, protocol_id))
			continue;

		if (account_test && !account_test(account))
			continue;

		result = account;
		break;
	}

	g_free(who);

	return result;
}
コード例 #9
0
static void
received_im_msg_cb(GaimAccount *account, char *sender, char *buffer,
				   int flags, void *data)
{
	gaim_debug_misc("signals test", "received-im-msg (%s, %s, %s, %d)\n",
					gaim_account_get_username(account), sender, buffer,
					flags);
}
コード例 #10
0
static gboolean
sending_chat_msg_cb(GaimAccount *account, char **buffer, int id, void *data)
{
	gaim_debug_misc("signals test", "sending-chat-msg (%s, %s, %d)\n",
					gaim_account_get_username(account), *buffer, id);

	return FALSE;
}
コード例 #11
0
static void
received_chat_msg_cb(GaimAccount *account, char *sender, char *buffer,
					 GaimConversation *chat, void *data)
{
	gaim_debug_misc("signals test",
					"received-chat-msg (%s, %s, %s, %s)\n",
					gaim_account_get_username(account), sender, buffer,
					gaim_conversation_get_name(chat));
}
コード例 #12
0
static void
chat_invited_cb(GaimAccount *account, const char *inviter,
				const char *room_name, const char *message,
				const GHashTable *components, void *data)
{
	gaim_debug_misc("signals test", "chat-invited (%s, %s, %s, %s)\n",
					gaim_account_get_username(account), inviter,
					room_name, message);
}
コード例 #13
0
static gboolean
writing_im_msg_cb(GaimAccount *account, GaimConversation  *conv, char **buffer, void *data)
{
	gaim_debug_misc("signals test", "writing-im-msg (%s, %s, %s)\n",
					gaim_account_get_username(account), gaim_conversation_get_name(conv), *buffer);

	return FALSE;

}
コード例 #14
0
ファイル: irc.c プロジェクト: VoxOx/VoxOx
static void irc_login(GaimAccount *account)
{
	GaimConnection *gc;
	struct irc_conn *irc;
	char **userparts;
	const char *username = gaim_account_get_username(account);

	gc = gaim_account_get_connection(account);
	gc->flags |= GAIM_CONNECTION_NO_NEWLINES;

	if (strpbrk(username, " \t\v\r\n") != NULL) {
		gaim_connection_error(gc, _("IRC nicks may not contain whitespace"));
		return;
	}

	gc->proto_data = irc = g_new0(struct irc_conn, 1);
	irc->fd = -1;
	irc->account = account;
	irc->outbuf = gaim_circ_buffer_new(512);

	userparts = g_strsplit(username, "@", 2);
	gaim_connection_set_display_name(gc, userparts[0]);
	irc->server = g_strdup(userparts[1]);
	g_strfreev(userparts);

	irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal,
					     NULL, (GDestroyNotify)irc_buddy_free);
	irc->cmds = g_hash_table_new(g_str_hash, g_str_equal);
	irc_cmd_table_build(irc);
	irc->msgs = g_hash_table_new(g_str_hash, g_str_equal);
	irc_msg_table_build(irc);

	gaim_connection_update_progress(gc, _("Connecting"), 1, 2);

	if (gaim_account_get_bool(account, "ssl", FALSE)) {
		if (gaim_ssl_is_supported()) {
			irc->gsc = gaim_ssl_connect(account, irc->server,
					gaim_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT),
					irc_login_cb_ssl, irc_ssl_connect_failure, gc);
		} else {
			gaim_connection_error(gc, _("SSL support unavailable"));
			return;
		}
	}

	if (!irc->gsc) {

		if (gaim_proxy_connect(gc, account, irc->server,
				 gaim_account_get_int(account, "port", IRC_DEFAULT_PORT),
				 irc_login_cb, gc) == NULL)
		{
			gaim_connection_error(gc, _("Couldn't create socket"));
			return;
		}
	}
}
コード例 #15
0
static gboolean
receiving_im_msg_cb(GaimAccount *account, char **sender, char **buffer,
				   int *flags, void *data)
{
	gaim_debug_misc("signals test", "receiving-im-msg (%s, %s, %s, %d)\n",
					gaim_account_get_username(account), *sender, *buffer,
					*flags);

	return FALSE;
}
コード例 #16
0
ファイル: notification.c プロジェクト: VoxOx/VoxOx
static void
cvr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
{
	GaimAccount *account;

	account = cmdproc->session->account;

	msn_cmdproc_send(cmdproc, "USR", "TWN I %s",
					 gaim_account_get_username(account));
}
コード例 #17
0
void GaimChatMngr::ChatAddUsersCbk(GaimConversation *conv, GList *users, gboolean new_arrivals)
{
	GList *l;
	GaimAccount *gAccount = gaim_conversation_get_account(conv);
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount),
								GaimIMPrcl::GetEnumIMProtocol(gPrclId));
	mConvInfo_t *mConv = NULL;
	IMChatSession *chatSession = NULL;
	GaimIMChat *mChat = FindIMChat(*account);

	if (!mChat)
		LOG_FATAL("Can't find IMChat !");

	mConv = (mConvInfo_t *) conv->ui_data;
	chatSession = (IMChatSession *) mConv->conv_session;

	for (l = users; l != NULL; l = l->next)
	{
		GaimConvChatBuddy *gCCBuddy = (GaimConvChatBuddy *) l->data;

		if (gCCBuddy && strcmp(gaim_account_get_username(gAccount), (char *) gCCBuddy->name))
		{
			std::string buddy((char *) gCCBuddy->name);
			IMContact imContact(*account, buddy);

			if (chatSession->getIMContactSet().find(imContact) != chatSession->getIMContactSet().end())
			{
				LOG_DEBUG("IMContact for " + imContact.getContactId() + " already in IMContactSet");
			}
			else
			{
				((IMContactSet &) chatSession->getIMContactSet()).insert(imContact);

				if (chatSession->getIMContactSet().size() == 1)
					mChat->newIMChatSessionCreatedEvent(*mChat, *chatSession);

				LOG_DEBUG("IMContact " + imContact.getContactId() + " added to IMContactSet");
			}
			mChat->contactAddedEvent(*mChat, *chatSession, imContact);
		}
	}
}
コード例 #18
0
/* **************** IMWRAPPER/GAIM INTERFACE ****************** */
GaimIMChat *GaimChatMngr::FindIMChatByGaimConv(void *gConv)
{
	GaimAccount *gAccount = gaim_conversation_get_account((GaimConversation *) gConv);
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount),
													GaimIMPrcl::GetEnumIMProtocol(gPrclId));
	GaimIMChat *mChat = FindIMChat(*account);

	return mChat;
}
コード例 #19
0
static gboolean
receiving_chat_msg_cb(GaimAccount *account, char **sender, char **buffer,
					 GaimConversation *chat, void *data)
{
	gaim_debug_misc("signals test",
					"receiving-chat-msg (%s, %s, %s, %s)\n",
					gaim_account_get_username(account), *sender, *buffer,
					gaim_conversation_get_name(chat));

	return FALSE;
}
コード例 #20
0
ファイル: pounce.c プロジェクト: BackupTheBerlios/koopa-svn
static void
gaim_pounces_write(FILE *fp, GaimPounce *pounce)
{
	GaimAccount *pouncer;
	GaimPounceEvent events;
	char *pouncer_name;

	pouncer = gaim_pounce_get_pouncer(pounce);
	events  = gaim_pounce_get_events(pounce);

	pouncer_name = g_markup_escape_text(gaim_account_get_username(pouncer), -1);

	fprintf(fp, " <pounce ui='%s'>\n", pounce->ui_type);
	fprintf(fp, "  <account protocol='%s'>%s</account>\n",
			pouncer->protocol_id, pouncer_name);
	fprintf(fp, "  <pouncee>%s</pouncee>\n", gaim_pounce_get_pouncee(pounce));
	fprintf(fp, "  <events>\n");

	if (events & GAIM_POUNCE_SIGNON)
		fprintf(fp, "   <event type='sign-on'/>\n");
	if (events & GAIM_POUNCE_SIGNOFF)
		fprintf(fp, "   <event type='sign-off'/>\n");
	if (events & GAIM_POUNCE_AWAY)
		fprintf(fp, "   <event type='away'/>\n");
	if (events & GAIM_POUNCE_AWAY_RETURN)
		fprintf(fp, "   <event type='return-from-away'/>\n");
	if (events & GAIM_POUNCE_IDLE)
		fprintf(fp, "   <event type='idle'/>\n");
	if (events & GAIM_POUNCE_IDLE_RETURN)
		fprintf(fp, "   <event type='return-from-idle'/>\n");
	if (events & GAIM_POUNCE_TYPING)
		fprintf(fp, "   <event type='start-typing'/>\n");
	if (events & GAIM_POUNCE_TYPING_STOPPED)
		fprintf(fp, "   <event type='stop-typing'/>\n");

	fprintf(fp, "  </events>\n");
	fprintf(fp, "  <actions>\n");

	g_hash_table_foreach(pounce->actions, write_action_parameter_list, fp);

	fprintf(fp, "  </actions>\n");

	if (gaim_pounce_get_save(pounce))
		fprintf(fp, "  <save/>\n");

	fprintf(fp, " </pounce>\n");

	g_free(pouncer_name);
}
コード例 #21
0
void GaimChatMngr::ChatRemoveUsersCbk(GaimConversation *conv, GList *users)
{
	GList *l;
	GaimAccount *gAccount = gaim_conversation_get_account(conv);
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount),
								GaimIMPrcl::GetEnumIMProtocol(gPrclId));
	mConvInfo_t *mConv = NULL;
	IMChatSession *chatSession = NULL;
	GaimIMChat *mChat = FindIMChat(*account);

	if (!mChat)
		LOG_FATAL("Can't find IMChat !");

	mConv = (mConvInfo_t *) conv->ui_data;
	chatSession = (IMChatSession *) mConv->conv_session;

	for (l = users; l != NULL; l = l->next)
	{
		if (strcmp(gaim_account_get_username(gAccount), (char *) l->data))
		{
			std::string buddy((char *) l->data);
			IMContact imContact(*account, buddy);

			if (chatSession->getIMContactSet().find(imContact) == chatSession->getIMContactSet().end())
			{
				LOG_ERROR("IMContact for " + imContact.getContactId() + " not in IMContactSet");
			}
			else
			{
				LOG_DEBUG("IMContact " + imContact.getContactId() + " removed from IMContactSet");
				mChat->contactRemovedEvent(*mChat, *chatSession, buddy);
			}
		}
	}
}
コード例 #22
0
void GaimChatMngr::CreateConversationCbk(GaimConversation *conv, bool userCreated)
{
	GaimAccount *gAccount = gaim_conversation_get_account(conv);
	GaimConversationType chatType = gaim_conversation_get_type(conv);
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount),
		GaimIMPrcl::GetEnumIMProtocol(gPrclId));
	GaimIMChat *mChat = FindIMChat(*account);
	mConvInfo_t *mConv;

	if (chatType == GAIM_CONV_TYPE_IM)
	{
		IMChatSession *chatSession = NULL;

		// Check if it's a jabber contact, and remove his ressource
		std::string contactId = cleanContactId(std::string(gaim_conversation_get_name(conv)),
			GaimIMPrcl::GetEnumIMProtocol(gPrclId));

		IMContact imContact(*account, contactId);

		mConv = mChat->CreateChatSession(userCreated, *mChat);
		mConv->gaim_conv_session = conv;
 		conv->ui_data = mConv;

		chatSession = (IMChatSession *) mConv->conv_session;

		((IMContactSet &) chatSession->getIMContactSet()).insert(imContact);
		mChat->newIMChatSessionCreatedEvent(*mChat, *chatSession);

		mChat->contactAddedEvent(*mChat, *chatSession, imContact);
	}
	else if (chatType == GAIM_CONV_TYPE_CHAT)
	{
		int id = GetGaimConversationId(gaim_conversation_get_name(conv));

		if ((mConv = mChat->FindChatStructById(id)) == NULL)
		{
			mConv = mChat->CreateChatSession(userCreated, *mChat);
		}

		if (mConv->gaim_conv_session)
			gaim_conversation_destroy((GaimConversation *)mConv->gaim_conv_session);

		mConv->gaim_conv_session = conv;
		conv->ui_data = mConv;
	}
}
コード例 #23
0
void
gaim_connection_register(GaimConnection *gc)
{
	GaimAccount *account;
	GaimConnectionUiOps *ops;
	GaimPluginProtocolInfo *prpl_info = NULL;

	g_return_if_fail(gc != NULL);

	gaim_debug(GAIM_DEBUG_INFO, "connection",
			"Registering.  gc = %p\n", gc);

	ops = gaim_get_connection_ui_ops();

	if (gc->prpl != NULL)
	        prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
	else {
	        gchar *message = g_strdup_printf(_("Missing protocol plugin for %s"),
						 gaim_account_get_username(gaim_connection_get_account(gc)));

		gaim_debug(GAIM_DEBUG_ERROR, "connection",
			   "Could not get prpl info for %p\n", gc);
		gaim_notify_error(NULL, _("Registration Error"),
				  message, NULL);
		g_free(message);
		return;
	}

	account = gaim_connection_get_account(gc);

	if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED)
		return;

	gaim_connection_set_state(gc, GAIM_CONNECTING);

	connections = g_list_append(connections, gc);

	gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc);

	/* set this so we don't auto-reconnect after registering */
	gc->wants_to_die = TRUE;

	gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling register_user\n");

	prpl_info->register_user(account);
}
コード例 #24
0
ファイル: dialog.c プロジェクト: VoxOx/VoxOx
void
msn_show_sync_issue(MsnSession *session, const char *passport,
					const char *group_name)
{
	GaimConnection *gc;
	GaimAccount *account;
	MsnAddRemData *data;
	char *msg, *reason;

	account = session->account;
	gc = gaim_account_get_connection(account);

	data        = g_new0(MsnAddRemData, 1);
	data->who   = g_strdup(passport);
	data->group = g_strdup(group_name);
	data->gc    = gc;

	msg = g_strdup_printf(_("Buddy list synchronization issue in %s (%s)"),
						  gaim_account_get_username(account),
						  gaim_account_get_protocol_name(account));

	if (group_name != NULL)
	{
		reason = g_strdup_printf(_("%s on the local list is "
								   "inside the group \"%s\" but not on "
								   "the server list. "
								   "Do you want this buddy to be added?"),
								 passport, group_name);
	}
	else
	{
		reason = g_strdup_printf(_("%s is on the local list but "
								   "not on the server list. "
								   "Do you want this buddy to be added?"),
								 passport);
	}

	gaim_request_action(gc, NULL, msg, reason, GAIM_DEFAULT_ACTION_NONE, 
						data, 2,
						_("Yes"), G_CALLBACK(msn_add_cb),
						_("No"), G_CALLBACK(msn_rem_cb));

	g_free(reason);
	g_free(msg);
}
コード例 #25
0
ファイル: odc.c プロジェクト: VoxOx/VoxOx
/**
 * Write the given OdcFrame to a ByteStream and send it out
 * on the established PeerConnection.
 */
static void
peer_odc_send(PeerConnection *conn, OdcFrame *frame)
{
    GaimAccount *account;
    const char *username;
    size_t length;
    ByteStream bs;

    gaim_debug_info("oscar", "Outgoing ODC frame to %s with "
                    "type=0x%04x, flags=0x%04x, payload length=%u\n",
                    conn->sn, frame->type, frame->flags, frame->payload.len);

    account = gaim_connection_get_account(conn->od->gc);
    username = gaim_account_get_username(account);
    memcpy(frame->sn, username, strlen(username));
    memcpy(frame->cookie, conn->cookie, 8);

    length = 76;
    byte_stream_new(&bs, length + frame->payload.len);
    byte_stream_putraw(&bs, conn->magic, 4);
    byte_stream_put16(&bs, length);
    byte_stream_put16(&bs, frame->type);
    byte_stream_put16(&bs, frame->subtype);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_putraw(&bs, frame->cookie, 8);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put32(&bs, frame->payload.len);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, frame->encoding);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, frame->flags);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_putraw(&bs, frame->sn, 32);
    byte_stream_putraw(&bs, frame->payload.data, frame->payload.len);

    peer_connection_send(conn, &bs);

    g_free(bs.data);
}
コード例 #26
0
ファイル: notification.c プロジェクト: VoxOx/VoxOx
static void
group_error_helper(MsnSession *session, const char *msg, int group_id, int error)
{
	GaimAccount *account;
	GaimConnection *gc;
	char *reason = NULL;
	char *title = NULL;

	account = session->account;
	gc = gaim_account_get_connection(account);

	if (error == 224)
	{
		if (group_id == 0)
		{
			return;
		}
		else
		{
			const char *group_name;
			group_name =
				msn_userlist_find_group_name(session->userlist,
											 group_id);
			reason = g_strdup_printf(_("%s is not a valid group."),
									 group_name);
		}
	}
	else
	{
		reason = g_strdup(_("Unknown error."));
	}

	title = g_strdup_printf(_("%s on %s (%s)"), msg,
						  gaim_account_get_username(account),
						  gaim_account_get_protocol_name(account));
	gaim_notify_error(gc, NULL, title, reason);
	g_free(title);
	g_free(reason);
}
コード例 #27
0
void GaimPresenceMngr::UpdateAccountStatus(GaimAccount *gAccount, 
										   GaimStatus *old, 
										   GaimStatus *newstatus)
{
	GaimIMPresence *mIMPresence = NULL;
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount),
		GaimIMPrcl::GetEnumIMProtocol(gPrclId));

	if (!account)
		return;

	mIMPresence = FindIMPresence(*account);
	if (!mIMPresence)
	{
		LOG_FATAL("IMPresence not found!");
		return;
	}

	mIMPresence->myPresenceStatusEvent(*mIMPresence, EnumPresenceState::MyPresenceStatusOk, "");

}
コード例 #28
0
static void authorize_add_cb(struct _jabber_add_permit *jap)
{
	if(g_list_find(gaim_connections_get_all(), jap->gc)) {
		GaimBuddy *buddy = NULL;
		jabber_presence_subscription_set(jap->gc->proto_data, jap->who,
				"subscribed");

		buddy = gaim_find_buddy(jap->gc->account, jap->who);

		if (buddy) {
			JabberBuddy *jb = NULL;

			jb = jabber_buddy_find(jap->js, jap->who, TRUE);

			if ((jb->subscription & JABBER_SUB_TO) == 0) {
				char *buffer = NULL;
				struct _jabber_add_permit *jap2 = g_new0(struct _jabber_add_permit, 1);
				jap2->gc = jap->gc;
				jap2->who = g_strdup(jap->who);

				/* XXX: Tidy this up when not in string freeze */
				buffer = g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s%s"),
				                         jap->who, "", "", "",
				                         (gaim_connection_get_display_name(jap->gc) != NULL
				                            ? gaim_connection_get_display_name(jap->gc)
				                            : gaim_account_get_username(jap->gc->account)),
				                         ".", "",
				                         _("\n\nDo you wish to add him or her to your buddy list?"));

				gaim_request_action(NULL, NULL, _("Add buddy to your list?"),
				                    buffer, GAIM_DEFAULT_ACTION_NONE, jap2, 2,
				                    _("Add"),    G_CALLBACK(add_user_cb),
				                    _("Cancel"), G_CALLBACK(free_jabber_add_permit));

				g_free(buffer);

			} else
コード例 #29
0
void GaimChatMngr::WriteConvCbk(GaimConversation *conv, const char *name, const char *alias,
							const char *message, GaimMessageFlags flags,
							time_t mtime)
{
	if ((flags & GAIM_MESSAGE_RECV))
	{
		mConvInfo_t *mConv = (mConvInfo_t *)conv->ui_data;
		GaimIMChat *mIMChat = FindIMChatByGaimConv(conv);

		// Prevent from double message during a chat session
		if (strcmp(gaim_account_get_username(conv->account), name) == 0)
			return;

		// Check if it's a jabber contact, and remove his ressource
		GaimAccount *gAccount = gaim_conversation_get_account(conv);
		const char *gPrclId = gaim_account_get_protocol_id(gAccount);
		std::string contactId = cleanContactId(name,
			GaimIMPrcl::GetEnumIMProtocol(gPrclId));

		mIMChat->messageReceivedEvent(*mIMChat, 
			*((IMChatSession *)(mConv->conv_session)),
			contactId, std::string(message));
	}
}
コード例 #30
0
void
gaim_connection_connect(GaimConnection *gc)
{
	GaimAccount *account;
	GaimConnectionUiOps *ops;
	GaimPluginProtocolInfo *prpl_info = NULL;

	g_return_if_fail(gc != NULL);

	gaim_debug(GAIM_DEBUG_INFO, "connection",
			   "Connecting. gc = %p\n", gc);

	ops = gaim_get_connection_ui_ops();

	if (gc->prpl != NULL)
	        prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
	else {
	        gchar *message = g_strdup_printf(_("Missing protocol plugin for %s"),
						 gaim_account_get_username(gaim_connection_get_account(gc)));

		gaim_debug(GAIM_DEBUG_ERROR, "connection",
			   "Could not get prpl info for %p\n", gc);
		gaim_notify_error(NULL, _("Connection Error"),
				  message, NULL);
		g_free(message);
		return;
	}

	account = gaim_connection_get_account(gc);

	if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED)
		return;

	if (!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
			!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL) &&
			gaim_account_get_password(account) == NULL) {
		gchar *primary;
		gchar *escaped;
		const gchar *username = gaim_account_get_username(account);

		gaim_debug(GAIM_DEBUG_INFO, "connection", "Requesting password\n");
		gaim_connection_destroy(gc);
		escaped = g_markup_escape_text(username, strlen(username));
		primary = g_strdup_printf(_("Enter password for %s"), escaped);
		gaim_request_input(gc, NULL, primary, NULL, NULL, FALSE, TRUE,
						   _("OK"), G_CALLBACK(request_pass_ok_cb),
						   _("Cancel"), NULL, account);
		g_free(primary);
		g_free(escaped);

		return;
	}

	gaim_connection_set_state(gc, GAIM_CONNECTING);

	connections = g_list_append(connections, gc);

	gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc);

	gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling serv_login\n");

	serv_login(account);
}