mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
convert GNCIdType from an enum to a char*
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6035 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -202,25 +202,23 @@ add_event_type (ComponentEventInfo *cei, GNCIdType entity_type,
|
||||
if (cei == NULL)
|
||||
return;
|
||||
|
||||
switch (entity_type)
|
||||
if (!safe_strcmp (entity_type, GNC_ID_TRANS))
|
||||
{
|
||||
case GNC_ID_TRANS:
|
||||
if (or_in)
|
||||
cei->trans_event_mask |= event_mask;
|
||||
else
|
||||
cei->trans_event_mask = event_mask;
|
||||
break;
|
||||
|
||||
case GNC_ID_ACCOUNT:
|
||||
}
|
||||
else if (!safe_strcmp (entity_type, GNC_ID_ACCOUNT))
|
||||
{
|
||||
if (or_in)
|
||||
cei->account_event_mask |= event_mask;
|
||||
else
|
||||
cei->account_event_mask = event_mask;
|
||||
break;
|
||||
|
||||
default:
|
||||
PERR ("unexpected entity type: %d", entity_type);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
PERR ("unexpected entity type: %s", entity_type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,41 +232,37 @@ gnc_cm_event_handler (GUID *entity,
|
||||
add_event (&changes, entity, event_type, TRUE);
|
||||
|
||||
id_type = xaccGUIDType (entity, gnc_get_current_book ());
|
||||
switch (id_type)
|
||||
|
||||
if (!safe_strcmp (id_type, GNC_ID_TRANS))
|
||||
{
|
||||
case GNC_ID_TRANS:
|
||||
changes.trans_event_mask |= event_type;
|
||||
break;
|
||||
|
||||
case GNC_ID_ACCOUNT:
|
||||
}
|
||||
else if (!safe_strcmp (id_type, GNC_ID_ACCOUNT))
|
||||
{
|
||||
changes.account_event_mask |= event_type;
|
||||
break;
|
||||
|
||||
case GNC_ID_SPLIT:
|
||||
}
|
||||
else if (!safe_strcmp (id_type, GNC_ID_SPLIT))
|
||||
{
|
||||
/* split events are never generated by the engine, but might be
|
||||
* generated by a backend (viz. the postgres backend.)
|
||||
* Handle them just like transactions */
|
||||
changes.trans_event_mask |= event_type;
|
||||
break;
|
||||
|
||||
case GNC_ID_PRICE:
|
||||
}
|
||||
else if (!safe_strcmp (id_type, GNC_ID_PRICE))
|
||||
{
|
||||
/* hack alert -- FIXME - Price events not currently handled by CM */
|
||||
break;
|
||||
|
||||
case GNC_ID_NONE:
|
||||
break;
|
||||
|
||||
case GNC_ID_SCHEDXACTION:
|
||||
case GNC_ID_FREQSPEC:
|
||||
DEBUG( "FIXME for GNC_ID %d", id_type );
|
||||
break;
|
||||
|
||||
default: {
|
||||
;
|
||||
}
|
||||
else if (!safe_strcmp (id_type, GNC_ID_SCHEDXACTION) ||
|
||||
!safe_strcmp (id_type, GNC_ID_FREQSPEC))
|
||||
{
|
||||
DEBUG( "FIXME for GNC_ID %s", id_type );
|
||||
}
|
||||
else
|
||||
{
|
||||
char guid_str[GUID_ENCODING_LENGTH+1];
|
||||
guid_to_string_buff (entity, guid_str);
|
||||
PERR ("unexpected id type: %d for guid=%s", id_type, guid_str);
|
||||
break;
|
||||
}
|
||||
PERR ("unexpected id type: %s for guid=%s", id_type, guid_str);
|
||||
}
|
||||
|
||||
got_events = TRUE;
|
||||
@@ -434,10 +428,10 @@ gnc_gui_component_watch_entity_type (gint component_id,
|
||||
{
|
||||
ComponentInfo *ci;
|
||||
|
||||
if (entity_type != GNC_ID_TRANS &&
|
||||
entity_type != GNC_ID_ACCOUNT)
|
||||
if (safe_strcmp (entity_type, GNC_ID_TRANS) &&
|
||||
safe_strcmp (entity_type, GNC_ID_ACCOUNT))
|
||||
{
|
||||
PERR ("bad entity type: %d", entity_type);
|
||||
PERR ("bad entity type: %s", entity_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -266,21 +266,17 @@ pgendProcessEvents (Backend *bend)
|
||||
|
||||
/* lets see if the local cache has this item in it */
|
||||
local_obj_type = xaccGUIDType (&(ev->guid), be->book);
|
||||
if ((local_obj_type != GNC_ID_NONE) && (local_obj_type != ev->obj_type))
|
||||
if ((local_obj_type != GNC_ID_NONE) && (safe_strcmp (local_obj_type,
|
||||
ev->obj_type)))
|
||||
{
|
||||
PERR ("ouch! object type mismatch, local=%d, event=%d",
|
||||
PERR ("ouch! object type mismatch, local=%s, event=%s",
|
||||
local_obj_type, ev->obj_type);
|
||||
g_free (ev);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (ev->obj_type)
|
||||
if (!safe_strcmp (ev->obj_type, GNC_ID_ACCOUNT))
|
||||
{
|
||||
case GNC_ID_NONE:
|
||||
case GNC_ID_NULL:
|
||||
PERR ("bad event type");
|
||||
break;
|
||||
case GNC_ID_ACCOUNT:
|
||||
if (0 < timespec_cmp(&(ev->stamp), &(be->last_account)))
|
||||
{
|
||||
be->last_account = ev->stamp;
|
||||
@@ -304,10 +300,9 @@ pgendProcessEvents (Backend *bend)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case GNC_ID_TRANS:
|
||||
}
|
||||
else if (!safe_strcmp (ev->obj_type, GNC_ID_TRANS))
|
||||
{
|
||||
if (0 < timespec_cmp(&(ev->stamp), &(be->last_transaction)))
|
||||
{
|
||||
be->last_transaction = ev->stamp;
|
||||
@@ -334,21 +329,20 @@ pgendProcessEvents (Backend *bend)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case GNC_ID_SPLIT:
|
||||
}
|
||||
else if (!safe_strcmp (ev->obj_type, GNC_ID_SPLIT))
|
||||
{
|
||||
if (0 < timespec_cmp(&(ev->stamp), &(be->last_transaction)))
|
||||
be->last_transaction = ev->stamp;
|
||||
break;
|
||||
|
||||
case GNC_ID_PRICE:
|
||||
}
|
||||
else if (!safe_strcmp (ev->obj_type, GNC_ID_PRICE))
|
||||
{
|
||||
if (0 < timespec_cmp(&(ev->stamp), &(be->last_price)))
|
||||
be->last_price = ev->stamp;
|
||||
break;
|
||||
|
||||
default:
|
||||
PERR ("unknown guid type %d", ev->obj_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
PERR ("unknown guid type %s", ev->obj_type);
|
||||
}
|
||||
|
||||
/* get the local type again, since we created guid above */
|
||||
|
||||
@@ -813,21 +813,12 @@ sqlQuery_build (sqlQuery *sq, Query *q, GNCBook *book)
|
||||
break;
|
||||
|
||||
case PR_GUID:
|
||||
switch (pd->guid.id_type)
|
||||
{
|
||||
case GNC_ID_ACCOUNT:
|
||||
if (!safe_strcmp (pd->guid.id_type, GNC_ID_ACCOUNT))
|
||||
need_account = TRUE;
|
||||
break;
|
||||
|
||||
case GNC_ID_SPLIT:
|
||||
else if (!safe_strcmp (pd->guid.id_type, GNC_ID_SPLIT))
|
||||
need_entry = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case PR_KVP:
|
||||
if (pd->kvp.where & KVP_MATCH_SPLIT)
|
||||
need_entry = TRUE;
|
||||
@@ -1064,31 +1055,26 @@ sqlQuery_build (sqlQuery *sq, Query *q, GNCBook *book)
|
||||
|
||||
sq->pq = stpcpy (sq->pq, " (");
|
||||
|
||||
switch (pd->guid.id_type)
|
||||
{
|
||||
default:
|
||||
case GNC_ID_NULL:
|
||||
case GNC_ID_NONE:
|
||||
if (pd->guid.id_type == GNC_ID_NONE ||
|
||||
!safe_strcmp (pd->guid.id_type, GNC_ID_NULL))
|
||||
sq->pq = stpcpy(sq->pq, "FALSE ");
|
||||
break;
|
||||
|
||||
case GNC_ID_ACCOUNT:
|
||||
else if (!safe_strcmp (pd->guid.id_type, GNC_ID_ACCOUNT))
|
||||
{
|
||||
sq->pq = stpcpy(sq->pq, "gncAccount.accountGuid = '");
|
||||
sq->pq = guid_to_string_buff (&pd->guid.guid, sq->pq);
|
||||
sq->pq = stpcpy(sq->pq, "' ");
|
||||
break;
|
||||
|
||||
case GNC_ID_TRANS:
|
||||
}
|
||||
else if (!safe_strcmp (pd->guid.id_type, GNC_ID_TRANS))
|
||||
{
|
||||
sq->pq = stpcpy(sq->pq, "gncTransaction.transGuid = '");
|
||||
sq->pq = guid_to_string_buff (&pd->guid.guid, sq->pq);
|
||||
sq->pq = stpcpy(sq->pq, "' ");
|
||||
break;
|
||||
|
||||
case GNC_ID_SPLIT:
|
||||
}
|
||||
else if (!safe_strcmp (pd->guid.id_type, GNC_ID_SPLIT))
|
||||
{
|
||||
sq->pq = stpcpy(sq->pq, "gncEntry.entryGuid = '");
|
||||
sq->pq = guid_to_string_buff (&pd->guid.guid, sq->pq);
|
||||
sq->pq = stpcpy(sq->pq, "' ");
|
||||
break;
|
||||
}
|
||||
|
||||
sq->pq = stpcpy (sq->pq, ") ");
|
||||
|
||||
@@ -32,7 +32,7 @@ struct _gncBusinessObject {
|
||||
GncBusiness *gncBusinessCreate (GNCBook *book);
|
||||
void gncBusinessDestroy (GncBusiness *business);
|
||||
|
||||
/* Return the GNC Session from the Business Object */
|
||||
/* Return the GNCBook from the Business Object */
|
||||
GNCBook * gncBusinessGetBook (const GncBusiness *bus);
|
||||
|
||||
/* Obtain an object from the type and GUID */
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-book-p.h"
|
||||
|
||||
#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
|
||||
#define CACHE_REMOVE(str) g_cache_remove(gnc_engine_get_string_cache(), (str));
|
||||
|
||||
/** #defines ********************************************************/
|
||||
#define GNCID_DEBUG 0
|
||||
@@ -93,6 +95,7 @@ entity_node_destroy(gpointer key, gpointer value, gpointer not_used)
|
||||
GUID *guid = key;
|
||||
EntityNode *e_node = value;
|
||||
|
||||
CACHE_REMOVE (e_node->entity_type);
|
||||
e_node->entity_type = GNC_ID_NONE;
|
||||
e_node->entity = NULL;
|
||||
|
||||
@@ -156,7 +159,7 @@ print_node(gpointer key, gpointer value, gpointer not_used)
|
||||
GUID *guid = key;
|
||||
EntityNode *node = value;
|
||||
|
||||
fprintf(stderr, "%s %d %p\n",
|
||||
fprintf(stderr, "%s %s %p\n",
|
||||
guid_to_string(guid), node->entity_type, node->entity);
|
||||
}
|
||||
|
||||
@@ -188,7 +191,6 @@ GNCIdType
|
||||
xaccGUIDTypeEntityTable (const GUID * guid, GNCEntityTable *entity_table)
|
||||
{
|
||||
EntityNode *e_node;
|
||||
GNCIdType entity_type;
|
||||
|
||||
if (guid == NULL)
|
||||
return GNC_ID_NONE;
|
||||
@@ -199,11 +201,7 @@ xaccGUIDTypeEntityTable (const GUID * guid, GNCEntityTable *entity_table)
|
||||
if (e_node == NULL)
|
||||
return GNC_ID_NONE;
|
||||
|
||||
entity_type = e_node->entity_type;
|
||||
if ((entity_type <= GNC_ID_NONE) || (entity_type > LAST_GNC_ID))
|
||||
return GNC_ID_NONE;
|
||||
|
||||
return entity_type;
|
||||
return e_node->entity_type;
|
||||
}
|
||||
|
||||
GNCIdType
|
||||
@@ -272,7 +270,7 @@ xaccLookupEntity (GNCEntityTable *entity_table,
|
||||
if (e_node == NULL)
|
||||
return NULL;
|
||||
|
||||
if (e_node->entity_type != entity_type)
|
||||
if (safe_strcmp (e_node->entity_type, entity_type))
|
||||
return NULL;
|
||||
|
||||
return e_node->entity;
|
||||
@@ -290,15 +288,14 @@ xaccStoreEntity (GNCEntityTable *entity_table, gpointer entity,
|
||||
if (guid == NULL)
|
||||
return;
|
||||
|
||||
if ((entity_type <= GNC_ID_NONE) || (entity_type > LAST_GNC_ID))
|
||||
return;
|
||||
if (!entity_type) return;
|
||||
|
||||
if (guid_equal(guid, xaccGUIDNULL())) return;
|
||||
|
||||
xaccRemoveEntity (entity_table, guid);
|
||||
|
||||
e_node = g_new(EntityNode, 1);
|
||||
e_node->entity_type = entity_type;
|
||||
e_node->entity_type = CACHE_INSERT (entity_type);
|
||||
e_node->entity = entity;
|
||||
|
||||
new_guid = xaccGUIDMalloc ();
|
||||
@@ -325,7 +322,8 @@ xaccRemoveEntity (GNCEntityTable *entity_table, const GUID * guid)
|
||||
if (g_hash_table_lookup_extended(entity_table->hash, guid, &old_guid, &node))
|
||||
{
|
||||
e_node = node;
|
||||
if (e_node->entity_type == GNC_ID_NULL)
|
||||
|
||||
if (!safe_strcmp (e_node->entity_type, GNC_ID_NULL))
|
||||
return;
|
||||
|
||||
g_hash_table_remove (entity_table->hash, old_guid);
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "guid.h"
|
||||
#include "gnc-engine.h"
|
||||
|
||||
/* Identifiers are 'typed' with integers. The ids used in gnucash are
|
||||
/* Identifiers are 'typed' with strings. The ids used in gnucash are
|
||||
* defined below. An id with type GNC_ID_NONE does not refer to any
|
||||
* entity, although that may change as new ids are created. An id with
|
||||
* type GNC_ID_NULL does not refer to any entity, and will never refer
|
||||
@@ -45,21 +45,19 @@
|
||||
* actual entity, but that is not guaranteed. If an id does refer to
|
||||
* an entity, the type of the entity will match the type of the
|
||||
* identifier. */
|
||||
typedef enum
|
||||
{
|
||||
GNC_ID_NONE = 0,
|
||||
GNC_ID_NULL,
|
||||
GNC_ID_ACCOUNT,
|
||||
GNC_ID_TRANS,
|
||||
GNC_ID_SPLIT,
|
||||
GNC_ID_PRICE,
|
||||
GNC_ID_BOOK,
|
||||
GNC_ID_SESSION,
|
||||
GNC_ID_SCHEDXACTION,
|
||||
GNC_ID_FREQSPEC,
|
||||
LAST_GNC_ID = GNC_ID_FREQSPEC
|
||||
} GNCIdType;
|
||||
|
||||
typedef char * GNCIdType;
|
||||
|
||||
#define GNC_ID_NONE NULL
|
||||
#define GNC_ID_NULL "null"
|
||||
#define GNC_ID_ACCOUNT "Account"
|
||||
#define GNC_ID_TRANS "Trans"
|
||||
#define GNC_ID_SPLIT "Split"
|
||||
#define GNC_ID_PRICE "Price"
|
||||
#define GNC_ID_BOOK "Book"
|
||||
#define GNC_ID_SESSION "Session"
|
||||
#define GNC_ID_SCHEDXACTION "SchedXaction"
|
||||
#define GNC_ID_FREQSPEC "FreqSpec"
|
||||
|
||||
/* Return the type of an identifier. */
|
||||
GNCIdType xaccGUIDType (const GUID * guid, GNCBook *book);
|
||||
|
||||
@@ -198,7 +198,7 @@ xaccQueryPrint(Query * q)
|
||||
printf ("guid sense=%d\n", qt->data.guid.sense);
|
||||
guid_to_string_buff (&qt->data.guid.guid, buff);
|
||||
printf ("\tguid=%s\n", buff);
|
||||
printf ("\tid type=%d\n", qt->data.guid.id_type);
|
||||
printf ("\tid type=%s\n", qt->data.guid.id_type);
|
||||
break;
|
||||
}
|
||||
case PR_KVP: {
|
||||
@@ -1431,7 +1431,7 @@ xaccQueryTermEqual (QueryTerm *qt1, QueryTerm *qt2)
|
||||
case PD_GUID:
|
||||
if (!guid_equal (&qt1->data.guid.guid, &qt2->data.guid.guid))
|
||||
return FALSE;
|
||||
if (qt1->data.guid.id_type != qt2->data.guid.id_type)
|
||||
if (safe_strcmp (qt1->data.guid.id_type, qt2->data.guid.id_type))
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
@@ -2483,24 +2483,19 @@ xaccGUIDMatchPredicate(Split * s, PredicateData * pd)
|
||||
|
||||
guid = &pd->guid.guid;
|
||||
|
||||
switch (pd->guid.id_type)
|
||||
{
|
||||
case GNC_ID_NONE:
|
||||
case GNC_ID_NULL:
|
||||
default:
|
||||
if (pd->guid.id_type == GNC_ID_NONE ||
|
||||
!safe_strcmp (pd->guid.id_type, GNC_ID_NULL))
|
||||
return 0;
|
||||
|
||||
case GNC_ID_ACCOUNT:
|
||||
else if (!safe_strcmp (pd->guid.id_type, GNC_ID_ACCOUNT))
|
||||
return (xaccSplitGetAccount (s) ==
|
||||
xaccAccountLookupEntityTable (guid, s->entity_table));
|
||||
|
||||
case GNC_ID_TRANS:
|
||||
else if (!safe_strcmp (pd->guid.id_type, GNC_ID_TRANS))
|
||||
return (xaccSplitGetParent (s) ==
|
||||
xaccTransLookupEntityTable (guid, s->entity_table));
|
||||
|
||||
case GNC_ID_SPLIT:
|
||||
else if (!safe_strcmp (pd->guid.id_type, GNC_ID_SPLIT))
|
||||
return s == xaccSplitLookupEntityTable (guid, s->entity_table);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
@@ -329,18 +329,6 @@ gnc_scm2sort_type (SCM sort_type_scm)
|
||||
return gnc_gw_enum_scm2val ("<gnc:sort-type>", sort_type_scm);
|
||||
}
|
||||
|
||||
static SCM
|
||||
gnc_id_type2scm (GNCIdType id_type)
|
||||
{
|
||||
return gnc_gw_enum_val2scm ("<gnc:id-type>", id_type);
|
||||
}
|
||||
|
||||
static GNCIdType
|
||||
gnc_scm2id_type (SCM id_type_scm)
|
||||
{
|
||||
return gnc_gw_enum_scm2val ("<gnc:id-type>", id_type_scm);
|
||||
}
|
||||
|
||||
static SCM
|
||||
gnc_bitfield2scm (const char *typestr, int value)
|
||||
{
|
||||
@@ -857,7 +845,7 @@ gnc_queryterm2scm (QueryTerm *qt)
|
||||
|
||||
case PD_GUID:
|
||||
qt_scm = gh_cons (gnc_guid2scm (qt->data.guid.guid), qt_scm);
|
||||
qt_scm = gh_cons (gnc_id_type2scm (qt->data.guid.id_type), qt_scm);
|
||||
qt_scm = gh_cons (gh_str02scm (qt->data.guid.id_type), qt_scm);
|
||||
break;
|
||||
|
||||
case PD_KVP:
|
||||
@@ -1164,6 +1152,7 @@ gnc_scm2query_term_query (SCM query_term_scm)
|
||||
{
|
||||
GUID guid;
|
||||
GNCIdType id_type;
|
||||
char *tmp;
|
||||
|
||||
/* guid */
|
||||
if (gh_null_p (query_term_scm))
|
||||
@@ -1179,7 +1168,9 @@ gnc_scm2query_term_query (SCM query_term_scm)
|
||||
scm = gh_car (query_term_scm);
|
||||
query_term_scm = gh_cdr (query_term_scm);
|
||||
|
||||
id_type = gnc_scm2id_type (scm);
|
||||
tmp = gh_scm2newstr (scm, NULL);
|
||||
id_type = g_strdup (tmp);
|
||||
if (tmp) free (tmp);
|
||||
|
||||
xaccQueryAddGUIDMatch (q, &guid, id_type, QUERY_OR);
|
||||
}
|
||||
|
||||
@@ -451,9 +451,10 @@ gnc_tracking_dissociate_account(Account *inc_or_expense_account)
|
||||
"associated-stock-account");
|
||||
|
||||
stock_account_guid = kvp_value_get_guid(stock_account_kvpval);
|
||||
if(xaccGUIDTypeEntityTable(stock_account_guid,
|
||||
inc_or_expense_account->entity_table) ==
|
||||
GNC_ID_NULL)
|
||||
if(!safe_strcmp
|
||||
(xaccGUIDTypeEntityTable(stock_account_guid,
|
||||
inc_or_expense_account->entity_table),
|
||||
GNC_ID_NULL))
|
||||
return;
|
||||
|
||||
category_kvpval = kvp_frame_get_slot(current_account_kvpframe,
|
||||
|
||||
@@ -355,18 +355,6 @@
|
||||
(gw:wrap-non-native-type mod '<gnc:QueryTerm*>
|
||||
"QueryTerm *" "const QueryTerm *")
|
||||
|
||||
(let ((wt (gw:wrap-enumeration mod '<gnc:id-type>
|
||||
"GNCIdType" "const GNCIdType")))
|
||||
(gw:enum-add-value! wt "GNC_ID_NONE" 'gnc-id-none)
|
||||
(gw:enum-add-value! wt "GNC_ID_NULL" 'gnc-id-null)
|
||||
(gw:enum-add-value! wt "GNC_ID_ACCOUNT" 'gnc-id-account)
|
||||
(gw:enum-add-value! wt "GNC_ID_TRANS" 'gnc-id-trans)
|
||||
(gw:enum-add-value! wt "GNC_ID_SPLIT" 'gnc-id-split)
|
||||
(gw:enum-add-value! wt "GNC_ID_PRICE" 'gnc-id-price)
|
||||
(gw:enum-add-value! wt "GNC_ID_BOOK" 'gnc-id-book)
|
||||
(gw:enum-add-value! wt "GNC_ID_SCHEDXACTION" 'gnc-id-sched-xaction)
|
||||
(gw:enum-add-value! wt "GNC_ID_FREQSPEC" 'gnc-id-freq-spec))
|
||||
|
||||
(let ((wt (gw:wrap-enumeration mod '<gnc:query-op>
|
||||
"QueryOp" "const QueryOp")))
|
||||
(gw:enum-add-value! wt "QUERY_AND" 'query-and)
|
||||
|
||||
@@ -1250,7 +1250,7 @@ free_random_kvp_path (GSList *path)
|
||||
static GNCIdType
|
||||
get_random_id_type (void)
|
||||
{
|
||||
return get_random_int_in_range (0, LAST_GNC_ID);
|
||||
return get_random_string ();
|
||||
}
|
||||
|
||||
Query *
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "gnc-component-manager.h"
|
||||
#include "gnc-currency-edit.h"
|
||||
#include "gnc-date-edit.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-exp-parser.h"
|
||||
#include "gnc-gui-query.h"
|
||||
#include "gnc-ui.h"
|
||||
@@ -689,7 +690,7 @@ refresh_handler (GHashTable *changes, gpointer user_data)
|
||||
|
||||
new_account = xaccAccountLookup (&info->account, gnc_get_current_book ());
|
||||
|
||||
if (id_type == GNC_ID_NULL || old_account == new_account)
|
||||
if (!safe_strcmp (id_type, GNC_ID_NULL) || old_account == new_account)
|
||||
return;
|
||||
|
||||
xml = glade_get_widget_tree (info->window);
|
||||
|
||||
@@ -202,6 +202,7 @@ gnc_html_register_url_cb (const char *location, const char *label,
|
||||
else if (strncmp ("guid=", location, 5) == 0)
|
||||
{
|
||||
GUID guid;
|
||||
GNCIdType id_type;
|
||||
|
||||
if (!string_to_guid (location + 5, &guid))
|
||||
{
|
||||
@@ -209,20 +210,20 @@ gnc_html_register_url_cb (const char *location, const char *label,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (xaccGUIDType (&guid, gnc_get_current_book ()))
|
||||
id_type = xaccGUIDType (&guid, gnc_get_current_book ());
|
||||
if (id_type == GNC_ID_NONE || !safe_strcmp (id_type, GNC_ID_NULL))
|
||||
{
|
||||
case GNC_ID_NONE:
|
||||
case GNC_ID_NULL:
|
||||
result->error_message = g_strdup_printf (_("No such entity: %s"),
|
||||
location);
|
||||
return FALSE;
|
||||
|
||||
case GNC_ID_ACCOUNT:
|
||||
}
|
||||
else if (!safe_strcmp (id_type, GNC_ID_ACCOUNT))
|
||||
{
|
||||
account = xaccAccountLookup (&guid, gnc_get_current_book ());
|
||||
reg = regWindowSimple (account);
|
||||
break;
|
||||
|
||||
case GNC_ID_TRANS:
|
||||
}
|
||||
else if (!safe_strcmp (id_type, GNC_ID_TRANS))
|
||||
{
|
||||
trans = xaccTransLookup (&guid, gnc_get_current_book ());
|
||||
split = NULL;
|
||||
|
||||
@@ -241,9 +242,9 @@ gnc_html_register_url_cb (const char *location, const char *label,
|
||||
}
|
||||
|
||||
reg = regWindowSimple (xaccSplitGetAccount (split));
|
||||
break;
|
||||
|
||||
case GNC_ID_SPLIT:
|
||||
}
|
||||
else if (!safe_strcmp (id_type, GNC_ID_SPLIT))
|
||||
{
|
||||
split = xaccSplitLookup (&guid, gnc_get_current_book ());
|
||||
if (!split)
|
||||
{
|
||||
@@ -253,9 +254,9 @@ gnc_html_register_url_cb (const char *location, const char *label,
|
||||
}
|
||||
|
||||
reg = regWindowSimple (xaccSplitGetAccount (split));
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
else
|
||||
{
|
||||
result->error_message =
|
||||
g_strdup_printf (_("Unsupported entity type: %s"), location);
|
||||
return FALSE;
|
||||
|
||||
@@ -856,8 +856,9 @@ gnc_split_register_paste_current (SplitRegister *reg)
|
||||
trans_split_index = gnc_trans_split_index(trans, trans_split);
|
||||
|
||||
if ((gnc_split_register_get_default_account (reg) != NULL) &&
|
||||
(xaccGUIDType(&copied_leader_guid,
|
||||
gnc_get_current_book ()) != GNC_ID_NULL))
|
||||
(safe_strcmp (xaccGUIDType(&copied_leader_guid,
|
||||
gnc_get_current_book ()),
|
||||
GNC_ID_NULL)))
|
||||
{
|
||||
new_guid = &info->default_account;
|
||||
gnc_copy_trans_scm_onto_trans_swap_accounts(copied_item, trans,
|
||||
|
||||
Reference in New Issue
Block a user