GnuCash c935c2f+
Loading...
Searching...
No Matches
Files | Data Structures | Macros | Functions

An address is a helper object used by the GncOwner object (and its actual implementations GncCustomer, ::GncVendor and ::GncEmployee). More...

Files

file  gncAddress.h
 an Address object
 

Data Structures

struct  GncAddress
 

Macros

#define GNC_ADDRESS_MODULE_NAME   "gncAddress"
 
#define GNC_ID_ADDRESS   GNC_ADDRESS_MODULE_NAME
 
#define GNC_TYPE_ADDRESS   (gnc_address_get_type ())
 
#define GNC_ADDRESS(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ADDRESS, GncAddress))
 
#define GNC_ADDRESS_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ADDRESS, GncAddressClass))
 
#define GNC_IS_ADDRESS(o)    (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ADDRESS))
 
#define GNC_IS_ADDRESS_CLASS(k)    (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ADDRESS))
 
#define GNC_ADDRESS_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ADDRESS, GncAddressClass))
 
#define ADDRESS_NAME   "name"
 
#define ADDRESS_ONE   "number"
 
#define ADDRESS_TWO   "street"
 
#define ADDRESS_THREE   "locality"
 
#define ADDRESS_FOUR   "city"
 
#define ADDRESS_PHONE   "phone"
 
#define ADDRESS_FAX   "fax"
 
#define ADDRESS_EMAIL   "email"
 
#define ADDRESS_OWNER   "owner"
 

Functions

GType gnc_address_get_type (void)
 
gboolean gncAddressIsDirty (const GncAddress *addr)
 
int gncAddressCompare (const GncAddress *a, const GncAddress *b)
 compare two addresses
 
gboolean gncAddressEqual (const GncAddress *a, const GncAddress *b)
 Deeply compare two addresses.
 

Create/Destroy functions

GncAddressgncAddressCreate (QofBook *book, QofInstance *parent)
 
void gncAddressDestroy (GncAddress *addr)
 
void gncAddressBeginEdit (GncAddress *addr)
 
void gncAddressCommitEdit (GncAddress *addr)
 

Set functions

void gncAddressSetName (GncAddress *addr, const char *name)
 
void gncAddressSetAddr1 (GncAddress *addr, const char *addr1)
 
void gncAddressSetAddr2 (GncAddress *addr, const char *addr2)
 
void gncAddressSetAddr3 (GncAddress *addr, const char *addr3)
 
void gncAddressSetAddr4 (GncAddress *addr, const char *addr4)
 
void gncAddressSetPhone (GncAddress *addr, const char *phone)
 
void gncAddressSetFax (GncAddress *addr, const char *fax)
 
void gncAddressSetEmail (GncAddress *addr, const char *email)
 
void gncAddressClearDirty (GncAddress *address)
 

Get Functions

const char * gncAddressGetName (const GncAddress *addr)
 
const char * gncAddressGetAddr1 (const GncAddress *addr)
 
const char * gncAddressGetAddr2 (const GncAddress *addr)
 
const char * gncAddressGetAddr3 (const GncAddress *addr)
 
const char * gncAddressGetAddr4 (const GncAddress *addr)
 
const char * gncAddressGetPhone (const GncAddress *addr)
 
const char * gncAddressGetFax (const GncAddress *addr)
 
const char * gncAddressGetEmail (const GncAddress *addr)
 

Detailed Description

An address is a helper object used by the GncOwner object (and its actual implementations GncCustomer, ::GncVendor and ::GncEmployee).

An address stores the physical address, phone, fax and email properties of a GncOwner. The owner's name itself is stored in GncOwner.

Note
an address is not a separate entity. It is meant to be embedded in other objects (that is, there is no addressbook; there is no address database that is separate from the objects that use addresses; there is no 'foreach' that can be used to iterate over all addresses.)

QOF needs to handle all objects generically and to tie the address to an owner, QOF must be able to find each - as entities.

This allows QOF to follow the hierarchy of objects without having to call any application-specific routines.

To achieve this, new GncAddress routines have been added. An address is now created with a NULL parent and the parent set explicitly using the QOF object declaration. Whilst this adds functionality, it is important that a valid GncOwner entity is always set as a parent. This is an API issue - QOF will always set the parent provided that a suitable entity is passed to the qofAddressSetOwner routine. It is up to you to pass a suitable entity.

Macro Definition Documentation

◆ ADDRESS_EMAIL

#define ADDRESS_EMAIL   "email"

Definition at line 159 of file gncAddress.h.

◆ ADDRESS_FAX

#define ADDRESS_FAX   "fax"

Definition at line 158 of file gncAddress.h.

◆ ADDRESS_FOUR

#define ADDRESS_FOUR   "city"

Definition at line 156 of file gncAddress.h.

◆ ADDRESS_NAME

#define ADDRESS_NAME   "name"

Definition at line 152 of file gncAddress.h.

◆ ADDRESS_ONE

#define ADDRESS_ONE   "number"

Definition at line 153 of file gncAddress.h.

◆ ADDRESS_OWNER

#define ADDRESS_OWNER   "owner"

Definition at line 160 of file gncAddress.h.

◆ ADDRESS_PHONE

#define ADDRESS_PHONE   "phone"

Definition at line 157 of file gncAddress.h.

◆ ADDRESS_THREE

#define ADDRESS_THREE   "locality"

Definition at line 155 of file gncAddress.h.

◆ ADDRESS_TWO

#define ADDRESS_TWO   "street"

Definition at line 154 of file gncAddress.h.

◆ GNC_ADDRESS

#define GNC_ADDRESS (   o)     (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ADDRESS, GncAddress))

Definition at line 89 of file gncAddress.h.

◆ GNC_ADDRESS_CLASS

#define GNC_ADDRESS_CLASS (   k)     (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ADDRESS, GncAddressClass))

Definition at line 91 of file gncAddress.h.

◆ GNC_ADDRESS_GET_CLASS

#define GNC_ADDRESS_GET_CLASS (   o)     (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ADDRESS, GncAddressClass))

Definition at line 97 of file gncAddress.h.

◆ GNC_ADDRESS_MODULE_NAME

#define GNC_ADDRESS_MODULE_NAME   "gncAddress"

Definition at line 67 of file gncAddress.h.

◆ GNC_ID_ADDRESS

#define GNC_ID_ADDRESS   GNC_ADDRESS_MODULE_NAME

Definition at line 68 of file gncAddress.h.

◆ GNC_IS_ADDRESS

#define GNC_IS_ADDRESS (   o)     (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ADDRESS))

Definition at line 93 of file gncAddress.h.

◆ GNC_IS_ADDRESS_CLASS

#define GNC_IS_ADDRESS_CLASS (   k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ADDRESS))

Definition at line 95 of file gncAddress.h.

◆ GNC_TYPE_ADDRESS

#define GNC_TYPE_ADDRESS   (gnc_address_get_type ())

Definition at line 88 of file gncAddress.h.

Function Documentation

◆ gncAddressBeginEdit()

void gncAddressBeginEdit ( GncAddress addr)

Definition at line 474 of file gncAddress.c.

475{
476 qof_begin_edit (&addr->inst);
477}
gboolean qof_begin_edit(QofInstance *inst)
begin_edit

◆ gncAddressClearDirty()

void gncAddressClearDirty ( GncAddress address)

Definition at line 561 of file gncAddress.c.

562{
563 if (!addr) return;
564 addr->dirty = FALSE;
565}

◆ gncAddressCommitEdit()

void gncAddressCommitEdit ( GncAddress addr)

Definition at line 493 of file gncAddress.c.

494{
495 /* GnuCash 2.6.3 and earlier didn't handle address kvp's... */
496 if (qof_instance_has_kvp(QOF_INSTANCE(addr)))
497 gnc_features_set_used (qof_instance_get_book (QOF_INSTANCE (addr)), GNC_FEATURE_KVP_EXTRA_DATA);
498
499 if (!qof_commit_edit (QOF_INSTANCE(addr))) return;
500 qof_commit_edit_part2 (&addr->inst, gncAddressOnError,
501 gncAddressOnDone, address_free);
502}
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
gboolean qof_instance_has_kvp(QofInstance *inst)
Report whether a QofInstance has anything stored in KVP.
void gnc_features_set_used(QofBook *book, const gchar *feature)
Indicate that the current book uses the given feature.
gboolean qof_commit_edit_part2(QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *))
part2 – deal with the backend
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers

◆ gncAddressCompare()

int gncAddressCompare ( const GncAddress a,
const GncAddress b 
)

compare two addresses

Returns
0 if identical, -1 if a is empty or less than b and +1 if a is more than b or if b is empty.

Definition at line 567 of file gncAddress.c.

568{
569 if (!a && !b) return 0;
570 if (!a && b) return 1;
571 if (a && !b) return -1;
572
573 return g_strcmp0 (a->name, b->name);
574}

◆ gncAddressCreate()

GncAddress * gncAddressCreate ( QofBook book,
QofInstance parent 
)

Definition at line 309 of file gncAddress.c.

310{
311 GncAddress *addr;
312
313 if (!book) return NULL;
314
315 addr = g_object_new (GNC_TYPE_ADDRESS, NULL);
316 qof_instance_init_data(&addr->inst, GNC_ID_ADDRESS, book);
317 addr->book = book;
318 addr->dirty = FALSE;
319 addr->parent = prnt;
320
321 addr->name = CACHE_INSERT ("");
322 addr->addr1 = CACHE_INSERT ("");
323 addr->addr2 = CACHE_INSERT ("");
324 addr->addr3 = CACHE_INSERT ("");
325 addr->addr4 = CACHE_INSERT ("");
326 addr->phone = CACHE_INSERT ("");
327 addr->fax = CACHE_INSERT ("");
328 addr->email = CACHE_INSERT ("");
329
330 return addr;
331}
void qof_instance_init_data(QofInstance *inst, QofIdType type, QofBook *book)
Initialise the settings associated with an instance.

◆ gncAddressDestroy()

void gncAddressDestroy ( GncAddress addr)

Definition at line 365 of file gncAddress.c.

366{
367 if (!addr) return;
368 qof_instance_set_destroying(addr, TRUE);
369 gncAddressCommitEdit (addr);
370}

◆ gncAddressEqual()

gboolean gncAddressEqual ( const GncAddress a,
const GncAddress b 
)

Deeply compare two addresses.

Returns
TRUE if all fields match, FALSE otherwise

Definition at line 577 of file gncAddress.c.

578{
579 if (a == NULL && b == NULL) return TRUE;
580 if (a == NULL || b == NULL) return FALSE;
581
582 g_return_val_if_fail(GNC_IS_ADDRESS(a), FALSE);
583 g_return_val_if_fail(GNC_IS_ADDRESS(b), FALSE);
584
585 if (g_strcmp0(a->name, b->name) != 0)
586 {
587 PWARN("names differ: %s vs %s", a->name, b->name);
588 return FALSE;
589 }
590 if (g_strcmp0(a->addr1, b->addr1) != 0)
591 {
592 PWARN("address lines 1 differ: %s vs %s", a->addr1, b->addr1);
593 return FALSE;
594 }
595 if (g_strcmp0(a->addr2, b->addr2) != 0)
596 {
597 PWARN("address lines 2 differ: %s vs %s", a->addr2, b->addr1);
598 return FALSE;
599 }
600 if (g_strcmp0(a->addr3, b->addr3) != 0)
601 {
602 PWARN("address lines 3 differ: %s vs %s", a->addr3, b->addr3);
603 return FALSE;
604 }
605 if (g_strcmp0(a->addr4, b->addr4) != 0)
606 {
607 PWARN("address lines 4 differ: %s vs %s", a->addr4, b->addr4);
608 return FALSE;
609 }
610 if (g_strcmp0(a->phone, b->phone) != 0)
611 {
612 PWARN("phone numbers differ: %s vs %s", a->phone, b->phone);
613 return FALSE;
614 }
615 if (g_strcmp0(a->fax, b->fax) != 0)
616 {
617 PWARN("fax numbers differ: %s vs %s", a->fax, b->fax);
618 return FALSE;
619 }
620 if (g_strcmp0(a->email, b->email) != 0)
621 {
622 PWARN("email addresses differ: %s vs %s", a->email, b->email);
623 return FALSE;
624 }
625
626 return TRUE;
627}
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250

◆ gncAddressGetAddr1()

const char * gncAddressGetAddr1 ( const GncAddress addr)

Definition at line 513 of file gncAddress.c.

514{
515 if (!addr) return NULL;
516 return addr->addr1;
517}

◆ gncAddressGetAddr2()

const char * gncAddressGetAddr2 ( const GncAddress addr)

Definition at line 519 of file gncAddress.c.

520{
521 if (!addr) return NULL;
522 return addr->addr2;
523}

◆ gncAddressGetAddr3()

const char * gncAddressGetAddr3 ( const GncAddress addr)

Definition at line 525 of file gncAddress.c.

526{
527 if (!addr) return NULL;
528 return addr->addr3;
529}

◆ gncAddressGetAddr4()

const char * gncAddressGetAddr4 ( const GncAddress addr)

Definition at line 531 of file gncAddress.c.

532{
533 if (!addr) return NULL;
534 return addr->addr4;
535}

◆ gncAddressGetEmail()

const char * gncAddressGetEmail ( const GncAddress addr)

Definition at line 549 of file gncAddress.c.

550{
551 if (!addr) return NULL;
552 return addr->email;
553}

◆ gncAddressGetFax()

const char * gncAddressGetFax ( const GncAddress addr)

Definition at line 543 of file gncAddress.c.

544{
545 if (!addr) return NULL;
546 return addr->fax;
547}

◆ gncAddressGetName()

const char * gncAddressGetName ( const GncAddress addr)

Definition at line 507 of file gncAddress.c.

508{
509 if (!addr) return NULL;
510 return addr->name;
511}

◆ gncAddressGetPhone()

const char * gncAddressGetPhone ( const GncAddress addr)

Definition at line 537 of file gncAddress.c.

538{
539 if (!addr) return NULL;
540 return addr->phone;
541}

◆ gncAddressIsDirty()

gboolean gncAddressIsDirty ( const GncAddress addr)

Definition at line 555 of file gncAddress.c.

556{
557 if (!addr) return FALSE;
558 return addr->dirty;
559}

◆ gncAddressSetAddr1()

void gncAddressSetAddr1 ( GncAddress addr,
const char *  addr1 
)

Definition at line 411 of file gncAddress.c.

412{
413 if (!addr) return;
414 if (!addr1) return;
415 SET_STR(addr, addr->addr1, addr1);
416 mark_address (addr);
417 gncAddressCommitEdit (addr);
418}

◆ gncAddressSetAddr2()

void gncAddressSetAddr2 ( GncAddress addr,
const char *  addr2 
)

Definition at line 420 of file gncAddress.c.

421{
422 if (!addr) return;
423 if (!addr2) return;
424 SET_STR(addr, addr->addr2, addr2);
425 mark_address (addr);
426 gncAddressCommitEdit (addr);
427}

◆ gncAddressSetAddr3()

void gncAddressSetAddr3 ( GncAddress addr,
const char *  addr3 
)

Definition at line 429 of file gncAddress.c.

430{
431 if (!addr) return;
432 if (!addr3) return;
433 SET_STR(addr, addr->addr3, addr3);
434 mark_address (addr);
435 gncAddressCommitEdit (addr);
436}

◆ gncAddressSetAddr4()

void gncAddressSetAddr4 ( GncAddress addr,
const char *  addr4 
)

Definition at line 438 of file gncAddress.c.

439{
440 if (!addr) return;
441 if (!addr4) return;
442 SET_STR(addr, addr->addr4, addr4);
443 mark_address (addr);
444 gncAddressCommitEdit (addr);
445}

◆ gncAddressSetEmail()

void gncAddressSetEmail ( GncAddress addr,
const char *  email 
)

Definition at line 465 of file gncAddress.c.

466{
467 if (!addr) return;
468 if (!email) return;
469 SET_STR(addr, addr->email, email);
470 mark_address (addr);
471 gncAddressCommitEdit (addr);
472}

◆ gncAddressSetFax()

void gncAddressSetFax ( GncAddress addr,
const char *  fax 
)

Definition at line 456 of file gncAddress.c.

457{
458 if (!addr) return;
459 if (!fax) return;
460 SET_STR(addr, addr->fax, fax);
461 mark_address (addr);
462 gncAddressCommitEdit (addr);
463}

◆ gncAddressSetName()

void gncAddressSetName ( GncAddress addr,
const char *  name 
)

Definition at line 402 of file gncAddress.c.

403{
404 if (!addr) return;
405 if (!name) return;
406 SET_STR(addr, addr->name, name);
407 mark_address (addr);
408 gncAddressCommitEdit (addr);
409}

◆ gncAddressSetPhone()

void gncAddressSetPhone ( GncAddress addr,
const char *  phone 
)

Definition at line 447 of file gncAddress.c.

448{
449 if (!addr) return;
450 if (!phone) return;
451 SET_STR(addr, addr->phone, phone);
452 mark_address (addr);
453 gncAddressCommitEdit (addr);
454}