Ejemplo n.º 1
0
/* through callbacks, this function manages to drive both
 * the gtk and the cli sync. */
static gboolean
sync_run_internal(SyncStatus *status,
		LJRunVerbCallback sync_run_verb,
		LJSyncProgressCallback sync_progress,
		gpointer parent,
		GSList **warnings, GError **err) {
	GError *tmperr = NULL;
	gboolean success = FALSE;
	char *lastsync = NULL;

	status->js = journal_store_open(JAM_ACCOUNT(status->account), TRUE, &tmperr);
	if (!status->js) goto err;

	lastsync = journal_store_get_lastsync(status->js);

	if (!lj_sync_run(jam_account_lj_get_user(status->account), NULL /* usejournal */,
			lastsync,
			put_lastsync, sync_run_verb, put_entries, sync_progress,
			status, warnings, &tmperr))
		goto err;

	success = TRUE;

err:
	if (tmperr)
		g_propagate_error(err, tmperr);

	g_free(lastsync);
	if (status->js)
		journal_store_free(status->js);

	return success;
}
Ejemplo n.º 2
0
static GtkWidget*
cfriends_filter_settings(JamAccountLJ *acc) {
    GtkWidget *filter, *maskhbox, *l;
    SettingsWidget *sw;
    LJUser *u = jam_account_lj_get_user(acc);

    filter = groupedbox_new_with_text(_("Filter"));

    maskhbox = gtk_hbox_new(FALSE, 5);
    gtk_box_pack_start(GTK_BOX(maskhbox),
                       sw_make("cf_usemask"), FALSE, FALSE, 0);
    sw = sw_lookup("cf_mask");
    sw->conf = acc;
    sw->widget = gtk_button_new_with_label(_("Choose filter"));
    gtk_box_pack_start(GTK_BOX(maskhbox), GTK_WIDGET(sw->widget), FALSE, FALSE, 0);
    gtk_widget_set_sensitive(sw->widget, u->friendgroups != NULL);
    g_signal_connect_swapped(G_OBJECT(sw->widget), "clicked",
                             G_CALLBACK(run_cfmask_settings_dlg), sw);
    l = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(l),
                         _("<small>The filter chosen here only affects the "
                           "current user.</small>"));
    gtk_label_set_line_wrap(GTK_LABEL(l), TRUE);
    gtk_label_set_justify(GTK_LABEL(l), GTK_JUSTIFY_LEFT);

    groupedbox_pack(GROUPEDBOX(filter), maskhbox, FALSE);
    groupedbox_pack(GROUPEDBOX(filter), l, FALSE);

    return filter;
}
Ejemplo n.º 3
0
gboolean
run_console_command(ConsoleUI *cui, const char *command) {
	NetContext *ctx;
	LJConsoleCommand *cc;
	int i;

	console_print(cui, NULL, _("Running command: '"));
	console_print(cui, "command", command);
	console_print(cui, NULL, "'.\n");

	cc = lj_consolecommand_new(jam_account_lj_get_user(cui->account), command);

	ctx = net_ctx_gtk_new(GTK_WINDOW(cui->win), _("Running Command"));
	if (!net_run_verb_ctx((LJVerb*)cc, ctx, NULL)) {
		console_print(cui, "error", _("Error running command.\n"));
		lj_consolecommand_free(cc);
		net_ctx_gtk_free(ctx);
		return FALSE;
	}

	for (i = 0; i < cc->linecount; i++) {
		char *typename = name_from_type(cc->lines[i].type);
		console_print(cui, typename, cc->lines[i].text);
		console_print(cui, typename, "\n");
	}

	lj_consolecommand_free(cc);
	net_ctx_gtk_free(ctx);
	
	return TRUE;
}
Ejemplo n.º 4
0
gboolean 
login_run(GtkWindow *parent, JamAccountLJ *acc) {
	LJUser *u = jam_account_lj_get_user(acc);
	LJLogin *login;
	NetContext *ctx;

#ifndef G_OS_WIN32
	login = lj_login_new(u, "GTK2-LogJam/" PACKAGE_VERSION);
#else
	login = lj_login_new(u, "WinGTK2-LogJam/" PACKAGE_VERSION);
#endif

	ctx = net_ctx_gtk_new(parent, _("Logging In"));
	if (!net_run_verb_ctx((LJVerb*)login, ctx, NULL)) {
		lj_login_free(login);
		net_ctx_gtk_free(ctx);
		return FALSE;
	}

	if (login->message)
		jam_messagebox(parent, _("LiveJournal Message"), login->message);

	lj_login_free(login);
	net_ctx_gtk_free(ctx);

	acc->lastupdate = time(NULL);

	return TRUE;
}
Ejemplo n.º 5
0
static void
picture_store(JamView *view) {
	int sel = gtk_option_menu_get_history(GTK_OPTION_MENU(view->pic));
	LJUser *user = jam_account_lj_get_user(JAM_ACCOUNT_LJ(view->account));
	const char *pickw = NULL;

	if (sel > 0)
		pickw = g_slist_nth(user->pickws, sel-1)->data;

	jam_doc_set_picture(view->doc, pickw);
}
Ejemplo n.º 6
0
static void
picture_load(JamView *view) {
	const char *pic = jam_doc_get_picture(view->doc);
	GSList *l;
	int sel = 0;
	LJUser *user = jam_account_lj_get_user(JAM_ACCOUNT_LJ(view->account));

	if (pic) {
		for (l = user->pickws, sel = 1; l; l = l->next, sel++) {
			if (strcmp(pic, l->data) == 0)
				break;
		}
		if (l == NULL) sel = 0;
	}
	if (sel)
		show_meta(view, JAM_VIEW_PIC);
	if (picture_visible(view))
		gtk_option_menu_set_history(GTK_OPTION_MENU(view->pic), sel);
}
Ejemplo n.º 7
0
static void
picture_populate(JamView *view) {
	GtkWidget *menu;
	GtkWidget *item;
	GSList *l;
	LJUser *user = jam_account_lj_get_user(JAM_ACCOUNT_LJ(view->account));

	menu = gtk_menu_new();
	item = gtk_menu_item_new_with_label(_("[default]"));
	gtk_widget_show(item);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);

	for (l = user->pickws; l; l = l->next) {
		item = gtk_menu_item_new_with_label(l->data);
		g_object_set_data(G_OBJECT(item), KEY_PICTUREKEYWORD, l->data);
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
		gtk_widget_show(item);
	}

	gtk_option_menu_set_menu(GTK_OPTION_MENU(view->pic), menu);
}
Ejemplo n.º 8
0
static gboolean
editgroup_run(friend_group_edit_dlg *fged) {
	NetContext *ctx;
	LJEditFriendGroups *efg;
	int groupid;

	if (fged->editgroup) {
		groupid = fged->editgroup->id;
	} else {
		groupid = fged->freegroup;
	}

	efg = lj_editfriendgroups_new(jam_account_lj_get_user(fged->account));
	lj_editfriendgroups_add_edit(efg, groupid,
			gtk_entry_get_text(GTK_ENTRY(fged->egroupname)),
			gtk_toggle_button_get_active(
					GTK_TOGGLE_BUTTON(fged->cpublic)));

	ctx = net_ctx_gtk_new(GTK_WINDOW(fged->win), _("Modifying Friend Group"));
	if (!net_run_verb_ctx((LJVerb*)efg, ctx, NULL)) {
		lj_editfriendgroups_free(efg);
		net_ctx_gtk_free(ctx);
		return FALSE;
	}

	if (fged->editgroup == NULL) {
		/* we must create a new group */
		fged->editgroup = lj_friendgroup_new();
		fged->editgroup->id = fged->freegroup;
	}
	string_replace(&fged->editgroup->name,
			g_strdup(gtk_entry_get_text(GTK_ENTRY(fged->egroupname))));
	fged->editgroup->ispublic =
		gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fged->cpublic));

	lj_editfriendgroups_free(efg);
	net_ctx_gtk_free(ctx);
	return TRUE;
}
Ejemplo n.º 9
0
static gboolean
load_tags (GtkWindow *parent, JamAccountLJ *acc, gchar *journal, GSList **l) 
{
  LJGetTags *gettags;
  NetContext *ctx;
  
  ctx = net_ctx_gtk_new (parent, _("Loading Tags"));
  gettags = lj_gettags_new (jam_account_lj_get_user (acc), journal);
  if (!net_run_verb_ctx ((LJVerb*) gettags, ctx, NULL)) 
    { 
      lj_gettags_free (gettags, TRUE);
      net_ctx_gtk_free (ctx);
      return FALSE;
    }
  
  g_hash_table_foreach (gettags->tags, (GHFunc) tags_hash_list_cb, l);
  
  lj_gettags_free (gettags, FALSE);
  net_ctx_gtk_free (ctx);
  
  return TRUE;
}
Ejemplo n.º 10
0
LJEntry*
history_load_itemid(GtkWindow *parent, JamAccount *acc, const char *usejournal, int itemid) {
	NetContext *ctx;
	LJGetEventsSingle *getevents;
	LJEntry *entry;

	if (!JAM_ACCOUNT_IS_LJ(acc)) {
		g_warning("XXX blogger: history for blogger\n");
		return NULL;
	}

	getevents = lj_getevents_single_new(jam_account_lj_get_user(JAM_ACCOUNT_LJ(acc)), usejournal, itemid);
	ctx = net_ctx_gtk_new(parent, _("Loading Entry"));
	if (!net_run_verb_ctx((LJVerb*)getevents, ctx, NULL)) {
		lj_getevents_single_free(getevents, TRUE);
		net_ctx_gtk_free(ctx);
		return NULL;
	}
	entry = getevents->entry;
	lj_getevents_single_free(getevents, FALSE);
	net_ctx_gtk_free(ctx);

	return entry;
}