GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-ab-kvp.c
1 /*
2  * gnc-ab-kvp.c --
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, contact:
16  *
17  * Free Software Foundation Voice: +1-617-542-5942
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
19  * Boston, MA 02110-1301, USA [email protected]
20  */
21 
30 #include "config.h"
31 #include "gnc-ui-util.h"
32 
33 #include "gnc-ab-kvp.h"
34 
35 /* This static indicates the debugging module that this .o belongs to. */
36 G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
37 
38 const gchar *
40 {
41  gchar *id = NULL;
42  qof_instance_get (QOF_INSTANCE (a),
43  "ab-account-id", &id,
44  NULL);
45  return id;
46 }
47 
48 void
50 {
52  qof_instance_set (QOF_INSTANCE (a),
53  "ab-account-id", id,
54  NULL);
56 }
57 
58 const gchar *
60 {
61  gchar *code = NULL;
62  qof_instance_get (QOF_INSTANCE (a),
63  "ab-bank-code", &code,
64  NULL);
65  return code;
66 }
67 
68 void
69 gnc_ab_set_account_bankcode(Account *a, const gchar *code)
70 {
72  qof_instance_set (QOF_INSTANCE (a),
73  "ab-bank-code", code,
74  NULL);
76 }
77 
78 guint32
80 {
81  guint64 uid = 0LL;
82  qof_instance_get (QOF_INSTANCE (a),
83  "ab-account-uid", &uid,
84  NULL);
85  return (guint32)uid;
86 }
87 
88 void
90 {
92  qof_instance_set (QOF_INSTANCE (a),
93  "ab-account-uid", (guint64)uid,
94  NULL);
96 }
97 
100 {
101  Timespec *t = NULL;
102  qof_instance_get (QOF_INSTANCE (a),
103  "ab-trans-retrieval", &t,
104  NULL);
105  return *t;
106 }
107 
108 void
110 {
112  qof_instance_set (QOF_INSTANCE (a),
113  "ab-trans-retrieval", &time,
114  NULL);
116 }
117 
118 
119 #define AB_KEY "hbci"
120 #define AB_TEMPLATES "template-list"
121 static KvpFrame *gnc_ab_get_book_kvp(QofBook *b, gboolean create);
122 
123 
124 /* EFFECTIVE FRIEND FUNCTION */
125 extern KvpFrame *qof_instance_get_slots (const QofInstance *);
126 /* EFFECTIVE FRIEND FUNCTION */
127 extern void qof_instance_set_dirty_flag (gconstpointer inst, gboolean flag);
128 
129 GList *
131 {
132  KvpFrame *frame = gnc_ab_get_book_kvp(b, FALSE);
133  KvpValue *value = kvp_frame_get_slot(frame, AB_TEMPLATES);
134  return kvp_value_get_glist(value);
135 }
136 
137 void
138 gnc_ab_set_book_template_list(QofBook *b, GList *template_list)
139 {
140  KvpFrame *frame = gnc_ab_get_book_kvp(b, TRUE);
141  KvpValue *value = kvp_value_new_glist_nc(template_list);
142  kvp_frame_set_slot_nc(frame, AB_TEMPLATES, value);
143  qof_instance_set_dirty_flag(QOF_INSTANCE(b), TRUE);
144 }
145 
146 static KvpFrame *
147 gnc_ab_get_book_kvp(QofBook *b, gboolean create)
148 {
149  KvpFrame *toplevel = qof_instance_get_slots(QOF_INSTANCE(b));
150  KvpFrame *result = kvp_frame_get_frame(toplevel, AB_KEY);
151  if (!result && create)
152  {
153  result = kvp_frame_new();
154  kvp_frame_add_frame_nc(toplevel, AB_KEY, result);
155  }
156  return result;
157 }
guint32 gnc_ab_get_account_uid(const Account *a)
Definition: gnc-ab-kvp.c:79
Timespec gnc_ab_get_account_trans_retrieval(const Account *a)
Definition: gnc-ab-kvp.c:99
void qof_instance_get(const QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_get.
utility functions for the GnuCash UI
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
void kvp_frame_add_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld)
Store the given kvp_frame to the glist bag at the indicated path (non-copying)
void qof_instance_set(QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
const gchar * gnc_ab_get_account_bankcode(const Account *a)
Definition: gnc-ab-kvp.c:59
void gnc_ab_set_account_accountid(Account *a, const gchar *id)
Definition: gnc-ab-kvp.c:49
void gnc_ab_set_account_uid(Account *a, guint32 uid)
Definition: gnc-ab-kvp.c:89
void gnc_ab_set_account_trans_retrieval(Account *a, Timespec time)
Definition: gnc-ab-kvp.c:109
void kvp_frame_set_slot_nc(KvpFrame *frame, const gchar *key, KvpValue *value)
GList * kvp_value_get_glist(const KvpValue *value)
void gnc_ab_set_book_template_list(QofBook *b, GList *template_list)
Definition: gnc-ab-kvp.c:138
KvpValue * kvp_value_new_glist_nc(GList *lst)
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
struct KvpFrameImpl KvpFrame
Definition: kvp_frame.h:76
KvpFrame * kvp_frame_new(void)
const gchar * gnc_ab_get_account_accountid(const Account *a)
Definition: gnc-ab-kvp.c:39
KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path)
void gnc_ab_set_account_bankcode(Account *a, const gchar *code)
Definition: gnc-ab-kvp.c:69
AqBanking KVP handling.
GList * gnc_ab_get_book_template_list(QofBook *b)
Definition: gnc-ab-kvp.c:130
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80
const gchar * QofLogModule
Definition: qofid.h:89