static void destroy_sx_on_book_close(QofInstance *ent, gpointer data) { SchedXaction* sx = GNC_SCHEDXACTION(ent); gnc_sx_begin_edit(sx); xaccSchedXactionDestroy(sx); }
static void sxftd_close(SXFromTransInfo *sxfti, gboolean delete_sx) { if ( sxfti->sx && delete_sx ) { gnc_sx_begin_edit(sxfti->sx); xaccSchedXactionDestroy(sxfti->sx); } sxfti->sx = NULL; gtk_widget_destroy (GTK_WIDGET (sxfti->dialog)); }
static void _destroy_sx(gpointer data, gpointer user_data) { SchedXactions *sxes; SchedXaction *sx = (SchedXaction*)data; QofBook *book; book = gnc_get_current_book(); sxes = gnc_book_get_schedxactions(book); gnc_sxes_del_sx(sxes, sx); gnc_sx_begin_edit(sx); xaccSchedXactionDestroy(sx); }
static void sxftd_destroy( GtkWidget *w, gpointer user_data ) { SXFromTransInfo *sxfti = (SXFromTransInfo*)user_data; if ( sxfti->sx ) { gnc_sx_begin_edit(sxfti->sx); xaccSchedXactionDestroy(sxfti->sx); sxfti->sx = NULL; } g_object_unref(G_OBJECT(sxfti->dense_cal_model)); g_object_unref(G_OBJECT(sxfti->example_cal)); g_free(sxfti); }
static gboolean gnc_schedXaction_end_handler(gpointer data_for_children, GSList* data_from_children, GSList* sibling_data, gpointer parent_data, gpointer global_data, gpointer *result, const gchar *tag) { SchedXaction *sx; gboolean successful = FALSE; xmlNodePtr tree = (xmlNodePtr)data_for_children; gxpf_data *gdata = (gxpf_data*)global_data; struct sx_pdata sx_pdata; if ( parent_data ) { return TRUE; } if ( !tag ) { return TRUE; } g_return_val_if_fail( tree, FALSE ); sx = xaccSchedXactionMalloc( gdata->bookdata ); memset(&sx_pdata, 0, sizeof(sx_pdata)); sx_pdata.sx = sx; sx_pdata.book = gdata->bookdata; g_assert( sx_dom_handlers != NULL ); successful = dom_tree_generic_parse( tree, sx_dom_handlers, &sx_pdata ); if (!successful) { g_critical("failed to parse scheduled xaction"); xmlElemDump( stdout, NULL, tree ); gnc_sx_begin_edit( sx ); xaccSchedXactionDestroy( sx ); goto done; } if (tree->properties) { gchar *sx_name = xaccSchedXactionGetName(sx); xmlAttr *attr; for (attr = tree->properties; attr != NULL; attr = attr->next) { xmlChar *attr_value = attr->children->content; g_debug("sx attribute name[%s] value[%s]", attr->name, attr_value); if (strcmp((const char *)attr->name, "version") != 0) { g_warning("unknown sx attribute [%s]", attr->name); continue; } // if version == 1.0.0: ensure freqspec, no recurrence // if version == 2.0.0: ensure recurrence, no freqspec. if (strcmp((const char *)attr_value, schedxaction_version_string) == 0) { if (!sx_pdata.saw_freqspec) g_critical("did not see freqspec in version 1 sx [%s]", sx_name); if (sx_pdata.saw_recurrence) g_warning("saw recurrence in supposedly version 1 sx [%s]", sx_name); } if (strcmp((const char *)attr_value, schedxaction_version2_string) == 0) { if (sx_pdata.saw_freqspec) g_warning("saw freqspec in version 2 sx [%s]", sx_name); if (!sx_pdata.saw_recurrence) g_critical("did not find recurrence in version 2 sx [%s]", sx_name); } } } // generic_callback -> book_callback: insert the SX in the book gdata->cb( tag, gdata->parsedata, sx ); /* FIXME: this should be removed somewhere near 1.8 release time. */ if ( sx->template_acct == NULL ) { Account *ra = NULL; const char *id = NULL; Account *acct = NULL; sixtp_gdv2 *sixdata = gdata->parsedata; QofBook *book; book = sixdata->book; /* We're dealing with a pre-200107<near-end-of-month> rgmerk change re: storing template accounts. */ /* Fix: get account with name of our GncGUID from the template accounts. Make that our template_acct pointer. */ /* THREAD-UNSAFE */ id = guid_to_string( xaccSchedXactionGetGUID( sx ) ); ra = gnc_book_get_template_root(book); if ( ra == NULL ) { g_warning( "Error getting template root account from being-parsed Book." ); xmlFreeNode( tree ); return FALSE; } acct = gnc_account_lookup_by_name( ra, id ); if ( acct == NULL ) { g_warning("no template account with name [%s]", id); xmlFreeNode( tree ); return FALSE; } g_debug("template account name [%s] for SX with GncGUID [%s]", xaccAccountGetName( acct ), id ); /* FIXME: free existing template account. * HUH????? We only execute this if there isn't * currently an existing template account, don't we? * <rgmerk> */ sx->template_acct = acct; } done: xmlFreeNode( tree ); return successful; }