static gint compare_status(PurpleBlistNode *node1, PurpleBlistNode *node2) {
	PurplePresence *p1=NULL, *p2=NULL;

	if(!node1) {
		return 0;
	}

	if(PURPLE_BLIST_NODE_IS_CHAT(node1) && PURPLE_BLIST_NODE_IS_CHAT(node2)) {
		return 0;
	} else if(PURPLE_BLIST_NODE_IS_CHAT(node1)) {
		return 1;
	} else if(PURPLE_BLIST_NODE_IS_CHAT(node2)) {
		return -1;
	}

	if(PURPLE_BLIST_NODE_IS_CONTACT(node1)) {
		p1 = purple_buddy_get_presence(
			purple_contact_get_priority_buddy((PurpleContact *)node1)
		);
	}

	if(node2 && PURPLE_BLIST_NODE_IS_CONTACT(node2)) {
		p2 = purple_buddy_get_presence(
			purple_contact_get_priority_buddy((PurpleContact *)node2)
		);
	}

	return purple_presence_compare(p1, p2);
}
Exemple #2
0
static char *plainprpl_status_text(PurpleBuddy *buddy)
{
	PurplePresence *presence;
	PurpleStatus *status;

	const char *status_name;
	const char *message;
	char *status_text;

	//purple_debug_info("plainprpl", "getting %s's status text for %s\n", buddy->name, buddy->account->username);

	presence = purple_buddy_get_presence(buddy);
	if (presence) {
		status = purple_presence_get_active_status(presence);
	} else {
		//printf("presence is null for ");
		status = NULL;
	}

	if (status) {
		status_name = purple_status_get_name(status);
		message = purple_status_get_attr_string(status, "message");

		if (message && strlen(message) > 0) {
			status_text = g_strdup_printf("%s: %s", status_name, message);
		} else {
			status_text = g_strdup(status_name);
		}
		//purple_debug_info("plainprpl", "%s's status text is %s\n", buddy->name, status_text);
		return status_text;
	} else {
		return g_strdup("Not logged in");
	}
}
Exemple #3
0
void IMInvoker::buddyEventCB(PurpleBuddy *buddy, PurpleBuddyEvent event) {
	if (!buddy)
		return;

	PurpleAccount *account = purple_buddy_get_account(buddy);
	GET_INSTANCE_IN_CALLBACK(account);
	if (!inst)
		return;

	switch (event) {
	case PURPLE_BUDDY_SIGNOFF:
	case PURPLE_BUDDY_SIGNON: {
		PurplePresence* presence = purple_buddy_get_presence(buddy);
		PurpleStatus* status = purple_presence_get_active_status(presence);
		buddyStatusChangedCB(buddy, NULL, status, event);
		break;
	}
	case PURPLE_BUDDY_ICON:
		break;

	default:
		break;
	}

}
Exemple #4
0
static void plainprpl_get_info(PurpleConnection *gc, const char *buddy_name)
{
	PurpleBuddy *buddy;
	plain_buddy_state *bstate;
	PurpleNotifyUserInfo *info;
	const char *addr_str;

	buddy = purple_find_buddy(gc->account, buddy_name);
	bstate = purple_buddy_get_protocol_data(buddy);
	info = purple_notify_user_info_new();

	if (bstate) {

		PurplePresence *presence = purple_buddy_get_presence(buddy);
		PurpleStatus *status = purple_presence_get_active_status(presence);
		const char *status_name = purple_status_get_name(status);

		purple_notify_user_info_add_pair(info, "Status", status_name);
		addr_str = purple_blist_node_get_string(PURPLE_BLIST_NODE(buddy), "addr_str");
		purple_notify_user_info_add_pair(info, "Address", addr_str);
		if (bstate->state == BUDDY_STATE_RESOLVE) {
			/* The IP address has not been resolved yet */
			purple_notify_user_info_add_pair(info, "Resolved", "Unknown");
		} else {
			purple_notify_user_info_add_pair(info, "Resolved", str_addr(&bstate->addr));
		}
		purple_notify_user_info_add_pair(info, "Last Seen", str_time(bstate->time_recv));
	} else {
		purple_notify_user_info_add_pair(info, "Info", "Missing Data");
	}

	/* Show a buddy's user info in a nice dialog box */
	purple_notify_userinfo(gc, buddy_name, info, NULL, NULL);
}
Exemple #5
0
/*
 * Subtypes 0x000b (SNAC_SUBTYPE_BUDDY_ONCOMING) and 0x000c (SNAC_SUBTYPE_BUDDY_OFFGOING) - Change in buddy status
 *
 * Oncoming Buddy notifications contain a subset of the
 * user information structure.  It's close enough to run
 * through aim_info_extract() however.
 *
 * Although the offgoing notification contains no information,
 * it is still in a format parsable by aim_info_extract().
 *
 */
static int
buddychange(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
{
	int ret = 0;
	aim_userinfo_t userinfo;
	aim_rxcallback_t userfunc;

	aim_info_extract(od, bs, &userinfo);

	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
		ret = userfunc(od, conn, frame, &userinfo);

	if (snac->subtype == SNAC_SUBTYPE_BUDDY_ONCOMING &&
	    userinfo.capabilities & OSCAR_CAPABILITY_XTRAZ) {
		PurpleAccount *account = purple_connection_get_account(od->gc);
		PurpleBuddy *buddy = purple_find_buddy(account, userinfo.bn);

		if (buddy) {
			PurplePresence *presence = purple_buddy_get_presence(buddy);

			if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOOD))
				icq_im_xstatus_request(od, userinfo.bn);
		}
	}
	aim_info_free(&userinfo);

	return ret;
}
Exemple #6
0
static void nullprpl_tooltip_text(PurpleBuddy *buddy,
                                  PurpleNotifyUserInfo *info,
                                  gboolean full) {
  PurpleConnection *gc = get_nullprpl_gc(purple_buddy_get_name(buddy));

  if (gc) {
    /* they're logged in */
    PurplePresence *presence = purple_buddy_get_presence(buddy);
    PurpleStatus *status = purple_presence_get_active_status(presence);
    char *msg = nullprpl_status_text(buddy);
	/* TODO: Check whether it's correct to call add_pair_html,
	         or if we should be using add_pair_plaintext */
    purple_notify_user_info_add_pair_html(info, purple_status_get_name(status),
                                     msg);
    g_free(msg);

    if (full) {
      const char *user_info = purple_account_get_user_info(purple_connection_get_account(gc));
      if (user_info)
		/* TODO: Check whether it's correct to call add_pair_html,
		         or if we should be using add_pair_plaintext */
        purple_notify_user_info_add_pair_html(info, _("User info"), user_info);
    }

  } else {
    /* they're not logged in */
    purple_notify_user_info_add_pair_plaintext(info, _("User info"), _("not logged in"));
  }

  purple_debug_info("nullprpl", "showing %s tooltip for %s\n",
                    (full) ? "full" : "short", purple_buddy_get_name(buddy));
}
Exemple #7
0
void purple_prpl_got_user_status_deactive(PurpleAccount *account, const char *name,
					const char *status_id)
{
	GSList *list, *l;
	PurpleBuddy *buddy;
	PurplePresence *presence;
	PurpleStatus *status;

	g_return_if_fail(account   != NULL);
	g_return_if_fail(name      != NULL);
	g_return_if_fail(status_id != NULL);
	g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account));

	if((list = purple_find_buddies(account, name)) == NULL)
		return;

	for(l = list; l != NULL; l = l->next) {
		buddy = l->data;

		presence = purple_buddy_get_presence(buddy);
		status   = purple_presence_get_status(presence, status_id);

		if(NULL == status)
			continue;

		if (purple_status_is_active(status)) {
			purple_status_set_active(status, FALSE);
			purple_blist_update_buddy_status(buddy, status);
		}
	}

	g_slist_free(list);
}
Exemple #8
0
static gboolean fx_send_attention(PurpleConnection *gc, const gchar *who, guint UNUSED(type))
{
	PurpleBuddy    *buddy;
	PurplePresence *presence;
	PurpleStatus   *status;
	const gchar    *status_id;
	fetion_account  *sec;
	fetion_account  *ac = purple_connection_get_protocol_data(gc);

	if(!(buddy = purple_find_buddy(ac->account, who))) return 0;
	presence = purple_buddy_get_presence(buddy);
	status   = purple_presence_get_active_status(presence);
	status_id = purple_status_get_id(status);

	/* online,need invite */
	if(strcmp(status_id, "Offline") != 0) {
		if(!(sec = session_find(who)))
			new_chat(ac, who, (gchar*)0);
		else 
			fetion_send_nudge(sec, who);
		return TRUE;
	}

	return FALSE;
}
Exemple #9
0
static char *nullprpl_status_text(PurpleBuddy *buddy) {
  purple_debug_info("nullprpl", "getting %s's status text for %s\n",
                    purple_buddy_get_name(buddy),
                    purple_account_get_username(purple_buddy_get_account(buddy)));

  if (purple_blist_find_buddy(purple_buddy_get_account(buddy), purple_buddy_get_name(buddy))) {
    PurplePresence *presence = purple_buddy_get_presence(buddy);
    PurpleStatus *status = purple_presence_get_active_status(presence);
    const char *name = purple_status_get_name(status);
    const char *message = purple_status_get_attr_string(status, "message");

    char *text;
    if (message && *message)
      text = g_strdup_printf("%s: %s", name, message);
    else
      text = g_strdup(name);

    purple_debug_info("nullprpl", "%s's status text is %s\n",
                      purple_buddy_get_name(buddy), text);
    return text;

  } else {
    purple_debug_info("nullprpl", "...but %s is not logged in\n", purple_buddy_get_name(buddy));
    return g_strdup("Not logged in");
  }
}
Exemple #10
0
static void
purplemot_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *info, int full)
{
  PurpleConnection *gc = get_purplemot_gc(buddy->name);

  if (gc) {
    /* they're logged in */
    PurplePresence *presence = purple_buddy_get_presence(buddy);
    PurpleStatus *status = purple_presence_get_active_status(presence);
    char *msg = purplemot_status_text(buddy);
    purple_notify_user_info_add_pair(info, purple_status_get_name(status),
                                     msg);
    g_free(msg);

    if (full) {
      const char *user_info = purple_account_get_user_info(gc->account);
      if (user_info)
        purple_notify_user_info_add_pair(info, _("User info"), user_info);
    }

  } else {
    /* they're not logged in */
    purple_notify_user_info_add_pair(info, _("User info"), _("not logged in"));
  }

  purple_debug_info("purplemot", "showing %s tooltip for %s\n",
                    (full) ? "full" : "short", buddy->name);
}
Exemple #11
0
static char *
purplemot_status_text(PurpleBuddy *buddy) {
  purple_debug_info("purplemot", "getting %s's status text for %s\n",
                    buddy->name, buddy->account->username);

  if (purple_find_buddy(buddy->account, buddy->name)) {
    PurplePresence *presence = purple_buddy_get_presence(buddy);
    PurpleStatus *status = purple_presence_get_active_status(presence);
    const char *name = purple_status_get_name(status);
    const char *message = purple_status_get_attr_string(status, "message");

    char *text;
    if (message && strlen(message) > 0)
      text = g_strdup_printf("%s: %s", name, message);
    else
      text = g_strdup(name);

    purple_debug_info("purplemot", "%s's status text is %s\n", buddy->name, text);
    return text;

  } else {
    purple_debug_info("purplemot", "...but %s is not logged in\n", buddy->name);
    return g_strdup("Not logged in");
  }
}
Exemple #12
0
int BuddyListNode::getBuddyStatusWeight(PurpleBuddy *buddy) const
{
  if (!purple_account_is_connected(purple_buddy_get_account(buddy)))
    return 0;

  PurplePresence *presence = purple_buddy_get_presence(buddy);
  PurpleStatus *status = purple_presence_get_active_status(presence);
  PurpleStatusType *status_type = purple_status_get_type(status);
  PurpleStatusPrimitive prim = purple_status_type_get_primitive(status_type);

  switch (prim) {
    case PURPLE_STATUS_OFFLINE:
      return 0;
    default:
      return 1;
    case PURPLE_STATUS_UNSET:
      return 2;
    case PURPLE_STATUS_UNAVAILABLE:
      return 3;
    case PURPLE_STATUS_AWAY:
      return 4;
    case PURPLE_STATUS_EXTENDED_AWAY:
      return 5;
    case PURPLE_STATUS_MOBILE:
      return 6;
    case PURPLE_STATUS_MOOD:
      return 7;
    case PURPLE_STATUS_TUNE:
      return 8;
    case PURPLE_STATUS_INVISIBLE:
      return 9;
    case PURPLE_STATUS_AVAILABLE:
      return 10;
  }
}
Exemple #13
0
void
purple_prpl_got_user_login_time(PurpleAccount *account, const char *name,
		time_t login_time)
{
	GSList *list;
	PurplePresence *presence;

	g_return_if_fail(account != NULL);
	g_return_if_fail(name    != NULL);

	if ((list = purple_find_buddies(account, name)) == NULL)
		return;

	if (login_time == 0)
		login_time = time(NULL);

	while (list) {
		PurpleBuddy *buddy = list->data;
		presence = purple_buddy_get_presence(buddy);
		list = g_slist_delete_link(list, list);

		if (purple_presence_get_login_time(presence) != login_time)
		{
			purple_presence_set_login_time(presence, login_time);

			purple_signal_emit(purple_blist_get_handle(), "buddy-got-login-time", buddy);
		}
	}
}
static gint compare_onofflinetime(PurpleBlistNode *node1, PurpleBlistNode *node2) {
	PurpleBuddy *buddy1=NULL, *buddy2=NULL;
	int t1=0, t2=0;
	
	if(!node1) {
		return 0;
	}

	if(PURPLE_BLIST_NODE_IS_CHAT(node1) && PURPLE_BLIST_NODE_IS_CHAT(node2)) {
		return 0;
	} else if(PURPLE_BLIST_NODE_IS_CHAT(node1)) {
		return 1;
	} else if(PURPLE_BLIST_NODE_IS_CHAT(node2)) {
		return -1;
	}

	if(PURPLE_BLIST_NODE_IS_CONTACT(node1)) {
		buddy1 = purple_contact_get_priority_buddy((PurpleContact *)node1);
	} else if(PURPLE_BLIST_NODE_IS_BUDDY(node1)) {
		buddy1 = (PurpleBuddy *)node1;
	}
	if(PURPLE_BUDDY_IS_ONLINE(buddy1)) {
		t1 = purple_presence_get_login_time(purple_buddy_get_presence(buddy1));
	} else {
		t1 = purple_blist_node_get_int((PurpleBlistNode *)buddy1, "last_seen");
	}

	if(PURPLE_BLIST_NODE_IS_CONTACT(node2)) {
		buddy2 = purple_contact_get_priority_buddy((PurpleContact *)node2);
	} else if(PURPLE_BLIST_NODE_IS_BUDDY(node2)) {
		buddy2 = (PurpleBuddy *)node2;
	}
	if(PURPLE_BUDDY_IS_ONLINE(buddy2)) {
		t2 = purple_presence_get_login_time(purple_buddy_get_presence(buddy2));
	} else {
		t2 = purple_blist_node_get_int((PurpleBlistNode *)buddy2, "last_seen");
	}
	
	if(t1 > t2) {
		return -1;
	}
	if(t2 > t1) {
		return 1;
	}
	return 0;
}
Exemple #15
0
/*
 * Returns the status message of a buddy.
 */
static const char *get_buddys_status_message(PurpleBuddy *buddy)
{
	const char *status_message = purple_status_get_attr_string(
			purple_presence_get_active_status(
				purple_buddy_get_presence(buddy)),
			"message");

	return (status_message)? status_message : "";
}
Exemple #16
0
static int fx_im_send(PurpleConnection *gc, const gchar *who, const gchar *what, PurpleMessageFlags UNUSED(flags))
{
	PurpleBuddy    *buddy;
	PurplePresence *presence;
	PurpleStatus   *status;
	const gchar    *status_id;
	fetion_account  *sec;
	PurpleConversation *conv;
	fetion_account  *ac = purple_connection_get_protocol_data(gc);

	Contact        *cnt;
	gint            shutdown = 0;

	if(!(buddy = purple_find_buddy(ac->account, who))) return 0;
	presence = purple_buddy_get_presence(buddy);
	status   = purple_presence_get_active_status(presence);
	status_id = purple_status_get_id(status);

	cnt = fetion_contact_list_find_by_userid(ac->user->contactList, who);
	if(cnt->relationStatus == RELATION_STATUS_UNAUTHENTICATED) {
		if(!(conv = purple_find_conversation_with_account(
						PURPLE_CONV_TYPE_ANY, who, ac->account))) return -1;
			purple_conversation_write(conv, NULL,
					  _("Failed to send message: Unverified Buddy!"),
					  PURPLE_MESSAGE_ERROR, time(NULL));
			return -1;
	}
	
	if(cnt->serviceStatus == BASIC_SERVICE_ABNORMAL){
		if(cnt->carrierStatus == CARRIER_STATUS_CLOSED){
			shutdown = 1;
		}else{
			if((cnt->carrier[0] != '\0' && cnt->mobileno[0] == '\0') || cnt->carrier[0] == '\0')
				shutdown = 1;
		}
	}else if(cnt->carrierStatus == CARRIER_STATUS_DOWN)
		if(cnt->carrier[0] != '\0') shutdown = 1;

	if(shutdown) {
		if(!(conv = purple_find_conversation_with_account(
						PURPLE_CONV_TYPE_ANY, who, ac->account))) return -1;
			purple_conversation_write(conv, NULL,
					  _("Fail to send message: Buddy has cancled Fetion service!"),
					  PURPLE_MESSAGE_ERROR, time(NULL));
			return -1;
	}

	/* online,need invite */
	if(strcmp(status_id, "Offline") != 0) {
		if(!(sec = session_find(who))) new_chat(ac, who, what);
		else  fetion_send_sms(sec, who, what);
		return 1;
	}

	fetion_send_sms(ac, who, what);
	return 1;
}
Exemple #17
0
/**
 * \brief Get string representation of buddy.
 *
 * This function returns the string-representation of a buddy in the format:
 * <tt>
 *     buddies name<TAB>buddies active status<TAB>buddies alias
 * </tt>
 *
 * \param buddy The buddy
 * \returns String representation of the buddy. The returned string has to
 *          be freed by the caller later on.
 */
static char *get_buddy_string(PurpleBuddy *buddy)
{
	return g_strdup_printf("%s\t%s\t%s\n",
			purple_buddy_get_name(buddy),
			purple_status_get_name(
				purple_presence_get_active_status(
					purple_buddy_get_presence(buddy))),
			purple_buddy_get_alias(buddy));
}
Exemple #18
0
const char *BuddyListNode::getBuddyStatus(PurpleBuddy *buddy) const
{
  if (!purple_account_is_connected(purple_buddy_get_account(buddy)))
    return "";

  PurplePresence *presence = purple_buddy_get_presence(buddy);
  PurpleStatus *status = purple_presence_get_active_status(presence);
  return Utils::getStatusIndicator(status);
}
Exemple #19
0
static gchar *
stress_status_text(PurpleBuddy *buddy) {
	PurplePresence *presence = purple_buddy_get_presence(buddy);
	PurpleStatus *status = purple_presence_get_active_status(presence);
	const gchar *msg = NULL;

	msg = purple_status_get_attr_string(status, "message");

	return (msg) ? g_strdup(msg) : NULL;
}
Exemple #20
0
char *PurpleLine::status_text(PurpleBuddy *buddy) {
    PurplePresence *presence = purple_buddy_get_presence(buddy);
    PurpleStatus *status = purple_presence_get_active_status(presence);

    const char *msg = purple_status_get_attr_string(status, "message");
    if (msg && msg[0])
        return g_markup_escape_text(msg, -1);

    return nullptr;
}
Exemple #21
0
static VALUE buddy_get_status( VALUE self ) {
  PurpleBuddy *buddy = NULL;
  PurpleStatus *status = NULL;
  PurpleStatusType *type = NULL;
  
  PURPLE_BUDDY( self, buddy );
  status = purple_presence_get_active_status( purple_buddy_get_presence( buddy ) );
  type = purple_status_get_type( status );
  
  return INT2NUM( purple_status_type_get_primitive( type ) );
}
Exemple #22
0
/*
   static void signed_on(PurpleConnection *gc, gpointer null)
   {
   taim_session *pses;
//GSList *bs;
//PurpleBuddy *btry;
PurpleAccount *account = purple_connection_get_account(gc);
purple_blist_add_account(account);
purple_blist_show();

// The hash is only added here
pses = uid_find_account(account);

if(pses)
{
pses->pses->account->hash_have = 1;

SHA1
(	
pses->pses->account->password_try, 
strlen(pses->pses->account->password_try), 
pses->pses->account->hash
);

memset(pses->pses->account->password_try, 0, 64);
}
}
*/
void drecurse(PurpleBlistNode *pnode, char*uid)
{	
  PurpleBuddy *pbuddy;
  PurplePresence *ppresence;

  taim_session *pses;
  gboolean gb;

  while(pnode) {
    if(pnode->child) {
      drecurse(pnode->child, uid);
    }

    switch(pnode->type) {
      case PURPLE_BLIST_GROUP_NODE:
        break;

      case PURPLE_BLIST_CONTACT_NODE:
        break;

      case PURPLE_BLIST_BUDDY_NODE:
        pbuddy = (PurpleBuddy*)pnode;
        ppresence = purple_buddy_get_presence(pbuddy);	
        gb = purple_presence_is_online(ppresence);

        if(gb)
        {
          pses = uid_find(uid);

          if(pses->pses->account->account && pbuddy->account)
          {
            if(strlen(pbuddy->account->username) == strlen(pses->pses->account->account->username))
            {
              if(!strcmp(pbuddy->account->username, pses->pses->account->account->username))
              {
                buddy_get(pses, pbuddy->name);
              }
            }
          }
        }
        break;

      case PURPLE_BLIST_CHAT_NODE:
        break;

      case PURPLE_BLIST_OTHER_NODE:
        break;
    }

    pnode = pnode->next;
  }
  return;
}
Exemple #23
0
static gchar *fx_status_text(PurpleBuddy *buddy)
{
	PurplePresence *presence;
	PurpleStatus   *status;
	const gchar    *msg;

	presence = purple_buddy_get_presence(buddy);
	status   = purple_presence_get_active_status(presence);
	msg = purple_status_get_attr_string(status, "impresa");
	if(msg && *msg)	return g_markup_escape_text(msg, -1);
	return NULL;
}
Exemple #24
0
void
purple_prpl_got_user_status(PurpleAccount *account, const char *name,
		const char *status_id, ...)
{
	GSList *list, *l;
	PurpleBuddy *buddy;
	PurplePresence *presence;
	PurpleStatus *status;
	PurpleStatus *old_status;
	va_list args;

	g_return_if_fail(account   != NULL);
	g_return_if_fail(name      != NULL);
	g_return_if_fail(status_id != NULL);
	g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account));

	if((list = purple_find_buddies(account, name)) == NULL)
		return;

	for(l = list; l != NULL; l = l->next) {
		buddy = l->data;

		presence = purple_buddy_get_presence(buddy);
		status   = purple_presence_get_status(presence, status_id);

		if(NULL == status)
			/*
			 * TODO: This should never happen, right?  We should call
			 *       g_warning() or something.
			 */
			continue;

		old_status = purple_presence_get_active_status(presence);

		va_start(args, status_id);
		purple_status_set_active_with_attrs(status, TRUE, args);
		va_end(args);

		purple_blist_update_buddy_status(buddy, old_status);
	}

	g_slist_free(list);

	/* The buddy is no longer online, they are therefore by definition not
	 * still typing to us. */
	if (!purple_status_is_online(status)) {
		serv_got_typing_stopped(purple_account_get_connection(account), name);
		purple_prpl_got_media_caps(account, name);
	}
}
Exemple #25
0
/* a short status text beside buddy icon*/
static gchar *np_status_text(PurpleBuddy *b)
{
    purple_debug_warning("np","\n===>");

    purple_debug_warning("np","\n===> ");
    
	PurpleStatus *status;
	PurplePresence *presence;
//	gchar *moodtext, *ret;
    
	presence = purple_buddy_get_presence(b);
	status = purple_presence_get_status(presence, "mood");
    
	/* we only provide Mood here
     switch(bd->status) {
    purple_debug_warning("np","\n===>");

     case np_BUDDY_OFFLINE:
     g_string_append(status, _("Offline"));
     break;
     case np_BUDDY_ONLINE_NORMAL:
     g_string_append(status, _("Online"));
     break;
     case np_BUDDY_CHANGE_TO_OFFLINE:
     g_string_append(status, _("Offline"));
     break;
     case np_BUDDY_ONLINE_AWAY:
     g_string_append(status, _("Away"));
     break;
     case np_BUDDY_ONLINE_INVISIBLE:
     g_string_append(status, _("Invisible"));
     break;
     case np_BUDDY_ONLINE_BUSY:
     g_string_append(status, _("Busy"));
     break;
     default:
     g_string_printf(status, _("Unknown-%d"), bd->status);
     }
     */
//	moodtext = purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT);
//	if (moodtext)
//	{
    purple_debug_warning("np","\n===>");

//		ret = g_strdup(moodtext);		//ret will be free by invoker
//		return ret;
//	}
    
	return NULL;
}
Exemple #26
0
void IMInvoker::buddyAddedCB(PurpleBuddy* buddy) {
	PurpleAccount *account = purple_buddy_get_account(buddy);
	GET_INSTANCE_IN_CALLBACK(account);
	if (!inst)
		return;

	std::string buddyName = purple_buddy_get_name(buddy);

	Event retEv("im.buddy.added");
	retEv.data.compound["name"] = Data(buddyName, Data::VERBATIM);
	inst->returnEvent(retEv);

	buddyStatusChangedCB(buddy, NULL, purple_presence_get_active_status(purple_buddy_get_presence(buddy)), PURPLE_BUDDY_NONE);

}
Exemple #27
0
void
oscar_user_info_append_extra_info(PurpleConnection *gc, PurpleNotifyUserInfo *user_info, PurpleBuddy *b, aim_userinfo_t *userinfo)
{
	OscarData *od;
	PurpleAccount *account;
	PurplePresence *presence = NULL;
	PurpleStatus *status = NULL;
	PurpleGroup *g = NULL;
	struct buddyinfo *bi = NULL;
	char *tmp;
	const char *bname = NULL, *gname = NULL;

	od = purple_connection_get_protocol_data(gc);
	account = purple_connection_get_account(gc);

	if ((user_info == NULL) || ((b == NULL) && (userinfo == NULL)))
		return;

	if (userinfo == NULL)
		userinfo = aim_locate_finduserinfo(od, purple_buddy_get_name(b));

	if (b == NULL)
		b = purple_find_buddy(account, userinfo->bn);

	if (b != NULL) {
		bname = purple_buddy_get_name(b);
		g = purple_buddy_get_group(b);
		gname = purple_group_get_name(g);
		presence = purple_buddy_get_presence(b);
		status = purple_presence_get_active_status(presence);
	}

	if (userinfo != NULL)
		bi = g_hash_table_lookup(od->buddyinfo, purple_normalize(account, userinfo->bn));

	if ((bi != NULL) && (bi->ipaddr != 0)) {
		tmp =  g_strdup_printf("%hhu.%hhu.%hhu.%hhu",
						(bi->ipaddr & 0xff000000) >> 24,
						(bi->ipaddr & 0x00ff0000) >> 16,
						(bi->ipaddr & 0x0000ff00) >> 8,
						(bi->ipaddr & 0x000000ff));
		oscar_user_info_add_pair(user_info, _("IP Address"), tmp);
		g_free(tmp);
	}
Exemple #28
0
void PurpleContactListMngr::UpdateBuddy(PurpleBuddyList *list, PurpleBuddy *gBuddy)
{
	IMAccount *account = NULL;
	PurpleAccount	*gAccount = purple_buddy_get_account(gBuddy);
	PurplePresence *gPresence = purple_buddy_get_presence(gBuddy);
	const char *gPrclId = purple_account_get_protocol_id(gAccount);
	
	account = _accountMngr->FindIMAccount(purple_account_get_username(gAccount),
		PurpleIMPrcl::GetEnumIMProtocol(gPrclId));
	
	if (account)
	{
		PurpleIMContactList *mIMBList = FindIMContactList(*account);
		PurpleIMPresence *mIMPresence = _presenceMngr->FindIMPresence(*account);
	

		if (mIMBList)
		{
			const char * groupName = FindBuddyGroup(gBuddy);
			if (groupName)
			{
				mIMBList->contactMovedEvent(*mIMBList,
					groupName, purple_buddy_get_name(gBuddy));
			}
		}

		if (mIMPresence)
		{
			const char* buddy_alias   = gBuddy->server_alias && *gBuddy->server_alias ? gBuddy->server_alias : gBuddy->alias;
			const char* statusMessage = PurpleIMPresence::getPurpleBuddyStatusMessage(gBuddy);
			const char* gPresenceId   = PurpleIMPresence::getPurplePresenceId(gPresence);

			//VOXOX - JRT - 2009.07.20 - COE in this method.  Is there a way to alert libpurple that we are quitting?
			//VOXOX - JRT - 2009.09.21 - Still here.  Let's see if we can catch problem in the parameters.
			EnumPresenceState::PresenceState presenceState = PurplePreState::GetPresenceState(gPresenceId);

			std::string   alias     = !buddy_alias   ? String::null : buddy_alias;
			std::string   statusMsg = !statusMessage ? String::null : statusMessage;
			const char*   from		= purple_buddy_get_name(gBuddy);

			mIMPresence->presenceStateChangedEvent(*mIMPresence, presenceState, alias, statusMsg, from );
		}
	}
}
Exemple #29
0
static void fx_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean UNUSED(full))
{
	PurpleStatus *status;
	const gchar *impresa, *alias, *sid, *mobileno;

	g_return_if_fail(buddy != NULL);

	status = purple_presence_get_active_status(purple_buddy_get_presence(buddy));
	impresa = purple_status_get_attr_string(status, "impresa");
	sid = purple_status_get_attr_string(status, "fetionno");
	mobileno = purple_status_get_attr_string(status, "mobileno");
	alias = purple_buddy_get_alias(buddy);

	purple_notify_user_info_add_pair(user_info, _("FetionNo"), sid);
	purple_notify_user_info_add_pair(user_info, _("MobileNo"), mobileno);
	purple_notify_user_info_add_pair(user_info, _("Alias"), alias);
	purple_notify_user_info_add_pair(user_info, _("Signature"), impresa);

}
Exemple #30
0
bool SpectrumBuddy::getStatus(PurpleStatusPrimitive &status, std::string &statusMessage) {
	PurplePresence *pres = purple_buddy_get_presence(m_buddy);
	if (pres == NULL)
		return false;
	PurpleStatus *stat = purple_presence_get_active_status(pres);
	if (stat == NULL)
		return false;
	status = purple_status_type_get_primitive(purple_status_get_type(stat));
	const char *message = purple_status_get_attr_string(stat, "message");

	if (message != NULL) {
		char *stripped = purple_markup_strip_html(message);
		statusMessage = std::string(stripped);
		g_free(stripped);
	}
	else
		statusMessage = "";
	return true;
}