GnuCash 2.4.99
import-utilities.c
00001 /********************************************************************\
00002  * This program is free software; you can redistribute it and/or    *
00003  * modify it under the terms of the GNU General Public License as   *
00004  * published by the Free Software Foundation; either version 2 of   *
00005  * the License, or (at your option) any later version.              *
00006  *                                                                  *
00007  * This program is distributed in the hope that it will be useful,  *
00008  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00009  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00010  * GNU General Public License for more details.                     *
00011  *                                                                  *
00012  * You should have received a copy of the GNU General Public License*
00013  * along with this program; if not, contact:                        *
00014  *                                                                  *
00015  * Free Software Foundation           Voice:  +1-617-542-5942       *
00016  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00017  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00018 \********************************************************************/
00026 #include "config.h"
00027 
00028 
00029 #include <glib.h>
00030 
00031 #include <stdlib.h>
00032 #include "import-utilities.h"
00033 #include "qof.h"
00034 #include "Account.h"
00035 #include "Transaction.h"
00036 
00037 
00038 /********************************************************************\
00039  * Setter and getter functions for the online_id kvp frame in
00040  * Account, Transaction and Split
00041 \********************************************************************/
00042 
00043 const gchar * gnc_import_get_acc_online_id(Account * account)
00044 {
00045     kvp_frame * frame;
00046     frame = xaccAccountGetSlots(account);
00047     return kvp_frame_get_string(frame, "online_id");
00048 }
00049 
00050 /* Used in the midst of editing a transaction; make it save the
00051  * account data. */
00052 void gnc_import_set_acc_online_id(Account * account,
00053                                   const gchar * string_value)
00054 {
00055     kvp_frame * frame;
00056     g_return_if_fail (account != NULL);
00057     frame = xaccAccountGetSlots(account);
00058     xaccAccountBeginEdit (account);
00059     kvp_frame_set_str(frame, "online_id", string_value);
00060     qof_instance_set_dirty (QOF_INSTANCE (account));
00061     xaccAccountCommitEdit (account);
00062 }
00063 
00064 const gchar * gnc_import_get_trans_online_id(Transaction * transaction)
00065 {
00066     kvp_frame * frame;
00067     frame = xaccTransGetSlots(transaction);
00068     return kvp_frame_get_string(frame, "online_id");
00069 }
00070 /* Not actually used */
00071 void gnc_import_set_trans_online_id(Transaction * transaction,
00072                                     const gchar * string_value)
00073 {
00074     kvp_frame * frame;
00075     frame = xaccTransGetSlots(transaction);
00076     kvp_frame_set_str (frame, "online_id", string_value);
00077 }
00078 
00079 gboolean gnc_import_trans_has_online_id(Transaction * transaction)
00080 {
00081     const gchar * online_id;
00082     online_id = gnc_import_get_trans_online_id(transaction);
00083     return (online_id != NULL && strlen(online_id) > 0);
00084 }
00085 
00086 const gchar * gnc_import_get_split_online_id(Split * split)
00087 {
00088     kvp_frame * frame;
00089     frame = xaccSplitGetSlots(split);
00090     return kvp_frame_get_string(frame, "online_id");
00091 }
00092 /* Used several places in a transaction edit where many other
00093  * parameters are also being set, so individual commits wouldn't be
00094  * appropriate. */
00095 void gnc_import_set_split_online_id(Split * split,
00096                                     const gchar * string_value)
00097 {
00098     kvp_frame * frame;
00099     frame = xaccSplitGetSlots(split);
00100     kvp_frame_set_str (frame, "online_id", string_value);
00101 }
00102 
00103 gboolean gnc_import_split_has_online_id(Split * split)
00104 {
00105     const gchar * online_id;
00106     online_id = gnc_import_get_split_online_id(split);
00107     return (online_id != NULL && strlen(online_id) > 0);
00108 }
00109 
00110 /* @} */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines