Ejemplo n.º 1
0
static void
save_savedstatus_cb(GntWidget *button, EditStatus *edit)
{
	const char *title, *message;
	PurpleStatusPrimitive prim;
	PurpleSavedStatus *find;

	title = gnt_entry_get_text(GNT_ENTRY(edit->title));
	message = gnt_entry_get_text(GNT_ENTRY(edit->message));
	if (!message || !*message)
		message = NULL;

	prim = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(edit->type)));

	if (!title || !*title)
	{
		purple_notify_error(edit, _("Error"), _("Invalid title"),
				_("Please enter a non-empty title for the status."));
		gnt_box_give_focus_to_child(GNT_BOX(edit->window), edit->title);
		return;
	}

	find = purple_savedstatus_find(title);
	if (find && find != edit->saved)
	{
		purple_notify_error(edit, _("Error"), _("Duplicate title"),
				_("Please enter a different title for the status."));
		gnt_box_give_focus_to_child(GNT_BOX(edit->window), edit->title);
		return;
	}
	
	if (edit->saved == NULL)
	{
		edit->saved = purple_savedstatus_new(title, prim);
		purple_savedstatus_set_message(edit->saved, message);
		set_substatuses(edit);
		if (statuses.tree)
			gnt_tree_add_row_last(GNT_TREE(statuses.tree), edit->saved,
					gnt_tree_create_row(GNT_TREE(statuses.tree), title,
						purple_primitive_get_name_from_type(prim), message), NULL);
	}
	else
	{
		purple_savedstatus_set_title(edit->saved, title);
		purple_savedstatus_set_type(edit->saved, prim);
		purple_savedstatus_set_message(edit->saved, message);
		if (statuses.tree)
		{
			gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 0, title);
			gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 1,
						purple_primitive_get_name_from_type(prim));
			gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 2, message);
		}
	}

	if (g_object_get_data(G_OBJECT(button), "use"))
		purple_savedstatus_activate(edit->saved);

	gnt_widget_destroy(edit->window);
}
Ejemplo n.º 2
0
xmlnode * _h_elim_status ( const char *name ,
                           const char *id   ,
                           SEXP_VALUE *args ,
                           gpointer    data )
{
    fprintf(stderr, "(elim-debug entered _h_elim_status)");
    ASSERT_ALISTP( args, id, name );
    
    elim_ping();

    const char *sid   = ALIST_VAL_STR( args, "status-id"      );
    const char *mesg  = ALIST_VAL_STR( args, "status-message" );
    signed int _stype = ALIST_VAL_INT( args, "status-type"    );

    PurpleSavedStatus   *status = purple_savedstatus_find( sid );
    PurpleStatusPrimitive stype = PURPLE_STATUS_UNSET;

    // create a new status:
    if( !status )
    {
        CHECK_STATUS ( args, id, name, stype, _stype );
        status = purple_savedstatus_new( sid, stype );
        if( status )
        {
            if     ( mesg ) purple_savedstatus_set_message( status, mesg );
            else if( sid  ) purple_savedstatus_set_message( status, sid  );
        }
    }
    else
    {
        if( mesg ) purple_savedstatus_set_message( status, mesg );
    }

    if( !status )
    {
        sexp_val_free( args );
        return response_error( EINVAL, id, name, "Could not create status" );
    }

    purple_savedstatus_activate( status );

    xmlnode *rval = xnode_new( "alist" );
    AL_STR ( rval, "status-id"     , purple_savedstatus_get_title  (status) );
    AL_STR ( rval, "status-message", purple_savedstatus_get_message(status) );
    AL_ENUM( rval, "status-type"   , purple_savedstatus_get_type   (status) , 
             ":status-primitive"   );
    
    sexp_val_free( args );
    fprintf(stderr, "(elim-debug leaving _h_elim_status)");
    return response_value( 0, id, name, rval );
}
Ejemplo n.º 3
0
static void
use_trans_status_cb(GntWidget *button, EditStatus *edit)
{
	const char *message;
	PurpleStatusPrimitive prim;
	PurpleSavedStatus *saved;

	message = gnt_entry_get_text(GNT_ENTRY(edit->message));
	prim = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(edit->type)));

	saved = purple_savedstatus_find_transient_by_type_and_message(prim, message);
	if (saved == NULL) {
		saved = purple_savedstatus_new(NULL, prim);
		edit->saved = saved;
		set_substatuses(edit);
	}
	purple_savedstatus_set_message(saved, message);
	purple_savedstatus_activate(saved);
	gnt_widget_destroy(edit->window);
}
Ejemplo n.º 4
0
/**
 * This method motivates Purple's Host (e.g. Pidgin) to update its UI
 * by using standard Purple's means of signals and saved statuses.
 *
 * Thus all UI elements get updated: Status Button with Note, docklet.
 * This is ablolutely important as both our status and note can come
 * inbound (roaming) or be updated programmatically (e.g. based on our
 * calendar data).
 */
void sipe_backend_status_and_note(struct sipe_core_public *sipe_public,
				  guint activity,
				  const gchar *message)
{
	struct sipe_backend_private *purple_private = sipe_public->backend_private;
	PurpleAccount *account = purple_private->account;
	const gchar *status_id = sipe_purple_activity_to_token(activity);
	PurpleSavedStatus *saved_status;
	const PurpleStatusType *acct_status_type =
		purple_status_type_find_with_id(account->status_types, status_id);
	PurpleStatusPrimitive primitive = purple_status_type_get_primitive(acct_status_type);

	saved_status = purple_savedstatus_find_transient_by_type_and_message(primitive, message);
	if (saved_status) {
		purple_savedstatus_set_substatus(saved_status, account, acct_status_type, message);
	}

	/* If this type+message is unique then create a new transient saved status
	 * Ref: gtkstatusbox.c
	 */
	if (!saved_status) {
		GList *tmp;
		GList *active_accts = purple_accounts_get_all_active();

		saved_status = purple_savedstatus_new(NULL, primitive);
		purple_savedstatus_set_message(saved_status, message);

		for (tmp = active_accts; tmp != NULL; tmp = tmp->next) {
			purple_savedstatus_set_substatus(saved_status,
							 (PurpleAccount *)tmp->data, acct_status_type, message);
		}
		g_list_free(active_accts);
	}

	/* Set the status for each account */
	purple_savedstatus_activate(saved_status);
}
Ejemplo n.º 5
0
/////////////////////////////////////////////////////////////////////////////
// The window procedure.  It handles WTS_SESSION_LOCK and WTS_SESSION_UNLOCK
//  messages sent to the LNR window.
/////////////////////////////////////////////////////////////////////////////
static LRESULT CALLBACK LnrWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    GList *accts, *iter;
    PurpleAccount *acct = NULL;
    PurpleStatusType *status_type = NULL;
    PurpleSavedStatus *saved_status = NULL;

    switch(uMsg)
    {
    case WM_WTSSESSION_CHANGE:
        switch(wParam)
        {
        case WTS_SESSION_LOCK:
        case WTS_REMOTE_DISCONNECT:

            saved_status = purple_savedstatus_new(NULL, purple_prefs_get_int(LNR_PREF_STATUS));
            purple_savedstatus_set_message(saved_status, purple_prefs_get_string(LNR_PREF_MESSAGE));

            iter = accts = purple_accounts_get_all_active();
            for(; iter != NULL; iter = iter->next)
            {
                acct = (PurpleAccount*)iter->data;
                if(lnr_should_change_message(acct))
                {
                    status_type = purple_account_get_status_type_with_primitive(acct, purple_prefs_get_int(LNR_PREF_STATUS));
                    if(status_type != NULL)
                    {
                        // Set the substatus for this account
                        purple_savedstatus_set_substatus(saved_status, acct, status_type, purple_prefs_get_string(LNR_PREF_MESSAGE));
                        lnr_accts = g_list_append(lnr_accts, acct);
                    }
                }
            }

            if(g_list_length(lnr_accts))
            {
                lnr_reactivate_status = purple_savedstatus_get_current();
                purple_savedstatus_activate(saved_status);
            }
            else
            {
                lnr_reactivate_status = NULL;
                g_list_free(lnr_accts);
                lnr_accts = NULL;
            }

            g_list_free(accts);
            accts = NULL;

            break;
            
        case WTS_SESSION_UNLOCK:
        case WTS_REMOTE_CONNECT:

            if(lnr_accts != NULL)
            {
                if (lnr_reactivate_status != NULL)
                {
                    purple_savedstatus_activate(lnr_reactivate_status);
                }
                else
                {
                    saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE);
                    purple_savedstatus_set_message(saved_status, "");

                    for(iter = lnr_accts; iter != NULL; iter = iter->next)
                    {
                        acct = (PurpleAccount*)iter->data;
                        // Set the status up with a generic "Available" message for each account
                        status_type = purple_account_get_status_type_with_primitive(acct, PURPLE_STATUS_AVAILABLE);
                        if(status_type != NULL)
                        {
                            purple_savedstatus_set_substatus(saved_status, acct, status_type, "");
                        }
                    }

                    purple_savedstatus_activate(saved_status);
                }

                lnr_reactivate_status = NULL;
                g_list_free(lnr_accts);
                lnr_accts = NULL;
            }
            break;
        }
        break;
    }

    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}