Import_Export


Files

file  import-account-matcher.h
 Generic and very flexible account matcher/picker.
file  import-backend.h
 Generic importer backend interface.
file  import-commodity-matcher.h
 A Generic commodity matcher/picker.
file  import-main-matcher.h
 Transaction matcher main window.
file  import-match-map.h
 Generic import mapper service, maps strings->accounts.
file  import-match-picker.h
 The transaction match picker dialog interface.
file  import-settings.h
 Import preference handling. User preference interface for transaction matching (for both the gui and the backend).
file  import-utilities.h
 Utility functions for writing import modules.

Modules

 Export a chart of accounts.

Data Structures

struct  _accountpickerdialog
struct  _transactioninfo
struct  _matchinfo
struct  _main_matcher_info
struct  _GncImportMatchMap
struct  account_token_count
struct  token_accounts_info
struct  account_probability
struct  account_info
struct  _transpickerdialog
struct  _genimportsettings
struct  _split_record

Getters/Setters for GNCImportTransInfo



GList * gnc_import_TransInfo_get_match_list (const GNCImportTransInfo *info)
Transactiongnc_import_TransInfo_get_trans (const GNCImportTransInfo *info)
gboolean gnc_import_TransInfo_is_balanced (const GNCImportTransInfo *info)
Splitgnc_import_TransInfo_get_fsplit (const GNCImportTransInfo *info)
GNCImportMatchInfognc_import_TransInfo_get_selected_match (const GNCImportTransInfo *info)
void gnc_import_TransInfo_set_selected_match (GNCImportTransInfo *info, GNCImportMatchInfo *match, gboolean selected_manually)
gboolean gnc_import_TransInfo_get_match_selected_manually (const GNCImportTransInfo *info)
GNCImportAction gnc_import_TransInfo_get_action (const GNCImportTransInfo *info)
void gnc_import_TransInfo_set_action (GNCImportTransInfo *info, GNCImportAction action)
Accountgnc_import_TransInfo_get_destacc (const GNCImportTransInfo *info)
void gnc_import_TransInfo_set_destacc (GNCImportTransInfo *info, Account *acc, gboolean selected_manually)
gboolean gnc_import_TransInfo_get_destacc_selected_manually (const GNCImportTransInfo *info)
void gnc_import_TransInfo_delete (GNCImportTransInfo *info)
GNCImportTransInfognc_import_TransInfo_new (Transaction *trans, GncImportMatchMap *matchmap)
gboolean gnc_import_TransInfo_refresh_destacc (GNCImportTransInfo *transaction_info, GncImportMatchMap *matchmap)

Getters/Setters for GNCImportMatchInfo



Splitgnc_import_MatchInfo_get_split (const GNCImportMatchInfo *info)
gint gnc_import_MatchInfo_get_probability (const GNCImportMatchInfo *info)

Non-GUI Functions



GdkPixbuf * gen_probability_pixbuf (gint score_original, GNCImportSettings *settings, GtkWidget *widget)
void gnc_import_find_split_matches (GNCImportTransInfo *trans_info, gint process_threshold, double fuzzy_amount_difference, gint match_date_hardlimit)
gboolean gnc_import_process_trans_item (GncImportMatchMap *matchmap, GNCImportTransInfo *trans_info)
gboolean gnc_import_exists_online_id (Transaction *trans)
void gnc_import_TransInfo_init_matches (GNCImportTransInfo *trans_info, GNCImportSettings *settings)
GncImportMatchMapgnc_imap_create_from_account (Account *acc)
GncImportMatchMapgnc_imap_create_from_book (GNCBook *book)

Getters/Setters for GNCImportSettings



double gnc_import_Settings_get_fuzzy_amount (GNCImportSettings *settings)
gboolean gnc_import_Settings_get_action_skip_enabled (GNCImportSettings *settings)
gboolean gnc_import_Settings_get_action_add_enabled (GNCImportSettings *settings)
gboolean gnc_import_Settings_get_action_edit_enabled (GNCImportSettings *settings)
gboolean gnc_import_Settings_get_action_clear_enabled (GNCImportSettings *settings)
gint gnc_import_Settings_get_clear_threshold (GNCImportSettings *settings)
gint gnc_import_Settings_get_add_threshold (GNCImportSettings *settings)
gint gnc_import_Settings_get_display_threshold (GNCImportSettings *settings)
void gnc_import_Settings_set_match_date_hardlimit (GNCImportSettings *s, gint m)
gint gnc_import_Settings_get_match_date_hardlimit (const GNCImportSettings *s)

Setter-getters

Setter and getter functions for the online_id kvp_frame for Accounts.

const gchar * gnc_import_get_acc_online_id (Account *account)
void gnc_import_set_acc_online_id (Account *account, const gchar *string_value)

Setter-getters

Setter and getter functions for the online_id kvp_frame for Transactions.

const gchar * gnc_import_get_trans_online_id (Transaction *transaction)
void gnc_import_set_trans_online_id (Transaction *transaction, const gchar *string_value)

Some well-known categories

NOTE: You DO NOT have to use these values in your importer -- these are just "well known" values, not "mandatory" values. You are free to use these if they apply, map your own fields to these labels, or create your own category strings.

#define GNCIMPORT_DESC   "desc"
#define GNCIMPORT_MEMO   "memo"
#define GNCIMPORT_PAYEE   "payee"

Defines

#define GCONF_SECTION   "dialogs/import/generic_matcher/account_matcher"
#define GCONF_SECTION   "dialogs/import/generic_matcher"
#define BAYES_OPTION   "use_bayes"
#define GCONF_SECTION   "dialogs/import/generic_matcher/transaction_list"
#define COLOR_RED   "brown1"
#define COLOR_YELLOW   "gold"
#define COLOR_GREEN   "DarkSeaGreen1"
#define IMAP_FRAME   "import-map"
#define IMAP_FRAME_BAYES   "import-map-bayes"
#define PROBABILITY_FACTOR   100000
#define threshold   (.90 * PROBABILITY_FACTOR)
#define GCONF_SECTION   "dialogs/import/generic_matcher/match_picker"
#define GCONF_SECTION   "dialogs/import/generic_matcher"
#define GCONF_SECTION   "dialogs/log_replay"
#define STRING_FIELD_SIZE   256
#define GCONF_SECTION   "dialogs/import/ofx"

Typedefs

typedef _transactioninfo GNCImportTransInfo
typedef _matchinfo GNCImportMatchInfo
typedef enum _action GNCImportAction
typedef _main_matcher_info GNCImportMainMatcher
typedef _GncImportMatchMap GncImportMatchMap
typedef _transpickerdialog GNCImportMatchPicker
typedef _genimportsettings GNCImportSettings
typedef _split_record split_record

Enumerations

enum  _action {
  GNCImport_SKIP, GNCImport_ADD, GNCImport_CLEAR, GNCImport_EDIT,
  GNCImport_LAST_ACTION, GNCImport_INVALID_ACTION
}
enum  downloaded_cols {
  DOWNLOADED_COL_DATE = 0, DOWNLOADED_COL_ACCOUNT, DOWNLOADED_COL_AMOUNT, DOWNLOADED_COL_DESCRIPTION,
  DOWNLOADED_COL_MEMO, DOWNLOADED_COL_ACTION_ADD, DOWNLOADED_COL_ACTION_CLEAR, DOWNLOADED_COL_ACTION_EDIT,
  DOWNLOADED_COL_ACTION_INFO, DOWNLOADED_COL_ACTION_PIXBUF, DOWNLOADED_COL_DATA, DOWNLOADED_COL_COLOR,
  NUM_DOWNLOADED_COLS, DOWNLOADED_COL_ACCOUNT = 0, DOWNLOADED_COL_DATE, DOWNLOADED_COL_AMOUNT,
  DOWNLOADED_COL_DESCRIPTION, DOWNLOADED_COL_MEMO, DOWNLOADED_COL_BALANCED, DOWNLOADED_COL_INFO_PTR,
  NUM_DOWNLOADED_COLS
}
enum  downloaded_cols {
  DOWNLOADED_COL_DATE = 0, DOWNLOADED_COL_ACCOUNT, DOWNLOADED_COL_AMOUNT, DOWNLOADED_COL_DESCRIPTION,
  DOWNLOADED_COL_MEMO, DOWNLOADED_COL_ACTION_ADD, DOWNLOADED_COL_ACTION_CLEAR, DOWNLOADED_COL_ACTION_EDIT,
  DOWNLOADED_COL_ACTION_INFO, DOWNLOADED_COL_ACTION_PIXBUF, DOWNLOADED_COL_DATA, DOWNLOADED_COL_COLOR,
  NUM_DOWNLOADED_COLS, DOWNLOADED_COL_ACCOUNT = 0, DOWNLOADED_COL_DATE, DOWNLOADED_COL_AMOUNT,
  DOWNLOADED_COL_DESCRIPTION, DOWNLOADED_COL_MEMO, DOWNLOADED_COL_BALANCED, DOWNLOADED_COL_INFO_PTR,
  NUM_DOWNLOADED_COLS
}
enum  matcher_cols {
  MATCHER_COL_CONFIDENCE = 0, MATCHER_COL_CONFIDENCE_PIXBUF, MATCHER_COL_DATE, MATCHER_COL_AMOUNT,
  MATCHER_COL_DESCRIPTION, MATCHER_COL_MEMO, MATCHER_COL_INFO_PTR, NUM_MATCHER_COLS
}

Functions

char * libgncmod_csv_gnc_module_path (void)
char * libgncmod_csv_gnc_module_description (void)
int libgncmod_csv_gnc_module_init (int refcount)
int libgncmod_csv_gnc_module_end (int refcount)
void gnc_file_aqbanking_import (const gchar *aqbanking_importername, const gchar *aqbanking_profilename, gboolean execute_transactions)
Accountgnc_import_select_account (gncUIWidget parent, const gchar *account_online_id_value, gboolean auto_create, const gchar *account_human_description, gnc_commodity *new_account_default_commodity, GNCAccountType new_account_default_type, Account *default_selection, gboolean *ok_pressed)
gnc_commoditygnc_import_select_commodity (char *cusip, char auto_create, char *default_fullname, char *default_mnemonic)
void gnc_gen_trans_list_delete (GNCImportMainMatcher *info)
GNCImportMainMatchergnc_gen_trans_list_new (GtkWidget *parent, const gchar *heading, gboolean all_from_same_account, gint match_date_hardlimit)
gboolean gnc_gen_trans_list_run (GNCImportMainMatcher *info)
void gnc_gen_trans_list_add_trans (GNCImportMainMatcher *gui, Transaction *trans)
void gnc_imap_destroy (GncImportMatchMap *imap)
void gnc_imap_clear (GncImportMatchMap *imap)
Accountgnc_imap_find_account (GncImportMatchMap *imap, const char *category, const char *key)
void gnc_imap_add_account (GncImportMatchMap *imap, const char *category, const char *key, Account *acc)
Accountgnc_imap_find_account_bayes (GncImportMatchMap *imap, GList *tokens)
void gnc_imap_add_account_bayes (GncImportMatchMap *imap, GList *tokens, Account *acc)
void gnc_import_match_picker_run_and_close (GNCImportTransInfo *transaction_info)
GNCImportSettingsgnc_import_Settings_new (void)
void gnc_import_Settings_delete (GNCImportSettings *settings)
void gnc_file_log_replay (void)
char * libgncmod_log_replay_gnc_module_path (void)
char * libgncmod_log_replay_gnc_module_description (void)
int libgncmod_log_replay_gnc_module_init (int refcount)
int libgncmod_log_replay_gnc_module_end (int refcount)
int ofx_proc_security_cb (const struct OfxSecurityData data, void *security_user_data)
int ofx_proc_transaction_cb (struct OfxTransactionData data, void *transaction_user_data)
int ofx_proc_account_cb (struct OfxAccountData data, void *account_user_data)
void gnc_file_ofx_import (void)
char * libgncmod_ofx_gnc_module_path (void)
char * libgncmod_ofx_gnc_module_description (void)
int libgncmod_ofx_gnc_module_init (int refcount)
int libgncmod_ofx_gnc_module_end (int refcount)

Variables

int libgncmod_csv_gnc_module_system_interface = 0
int libgncmod_csv_gnc_module_current = 0
int libgncmod_csv_gnc_module_revision = 0
int libgncmod_csv_gnc_module_age = 0
int libgncmod_log_replay_gnc_module_system_interface = 0
int libgncmod_log_replay_gnc_module_current = 0
int libgncmod_log_replay_gnc_module_revision = 0
int libgncmod_log_replay_gnc_module_age = 0
GNCImportMainMatchergnc_ofx_importer_gui = NULL
int libgncmod_ofx_gnc_module_system_interface = 0
int libgncmod_ofx_gnc_module_current = 0
int libgncmod_ofx_gnc_module_revision = 0
int libgncmod_ofx_gnc_module_age = 0


Define Documentation

#define PROBABILITY_FACTOR   100000

convert a hash table of account names and (struct account_probability*) into a hash table of 100000x the percentage match value, ie. 10% would be 0.10 * 100000 = 10000

Definition at line 223 of file import-match-map.c.


Enumeration Type Documentation

enum _action

Enumerator:
GNCImport_SKIP 
GNCImport_ADD 
GNCImport_CLEAR 
GNCImport_EDIT 
GNCImport_LAST_ACTION 
GNCImport_INVALID_ACTION 

Definition at line 38 of file import-backend.h.

00038                      {
00039   GNCImport_SKIP,
00040   GNCImport_ADD,
00041   GNCImport_CLEAR,
00042   GNCImport_EDIT,
00043   GNCImport_LAST_ACTION,
00044   GNCImport_INVALID_ACTION
00045 } GNCImportAction;

enum downloaded_cols

Enumerator:
DOWNLOADED_COL_DATE 
DOWNLOADED_COL_ACCOUNT 
DOWNLOADED_COL_AMOUNT 
DOWNLOADED_COL_DESCRIPTION 
DOWNLOADED_COL_MEMO 
DOWNLOADED_COL_ACTION_ADD 
DOWNLOADED_COL_ACTION_CLEAR 
DOWNLOADED_COL_ACTION_EDIT 
DOWNLOADED_COL_ACTION_INFO 
DOWNLOADED_COL_ACTION_PIXBUF 
DOWNLOADED_COL_DATA 
DOWNLOADED_COL_COLOR 
NUM_DOWNLOADED_COLS 
DOWNLOADED_COL_ACCOUNT 
DOWNLOADED_COL_DATE 
DOWNLOADED_COL_AMOUNT 
DOWNLOADED_COL_DESCRIPTION 
DOWNLOADED_COL_MEMO 
DOWNLOADED_COL_BALANCED 
DOWNLOADED_COL_INFO_PTR 
NUM_DOWNLOADED_COLS 

Definition at line 47 of file import-match-picker.c.

enum downloaded_cols

Enumerator:
DOWNLOADED_COL_DATE 
DOWNLOADED_COL_ACCOUNT 
DOWNLOADED_COL_AMOUNT 
DOWNLOADED_COL_DESCRIPTION 
DOWNLOADED_COL_MEMO 
DOWNLOADED_COL_ACTION_ADD 
DOWNLOADED_COL_ACTION_CLEAR 
DOWNLOADED_COL_ACTION_EDIT 
DOWNLOADED_COL_ACTION_INFO 
DOWNLOADED_COL_ACTION_PIXBUF 
DOWNLOADED_COL_DATA 
DOWNLOADED_COL_COLOR 
NUM_DOWNLOADED_COLS 
DOWNLOADED_COL_ACCOUNT 
DOWNLOADED_COL_DATE 
DOWNLOADED_COL_AMOUNT 
DOWNLOADED_COL_DESCRIPTION 
DOWNLOADED_COL_MEMO 
DOWNLOADED_COL_BALANCED 
DOWNLOADED_COL_INFO_PTR 
NUM_DOWNLOADED_COLS 

Definition at line 58 of file import-main-matcher.c.

enum matcher_cols

Enumerator:
MATCHER_COL_CONFIDENCE 
MATCHER_COL_CONFIDENCE_PIXBUF 
MATCHER_COL_DATE 
MATCHER_COL_AMOUNT 
MATCHER_COL_DESCRIPTION 
MATCHER_COL_MEMO 
MATCHER_COL_INFO_PTR 
NUM_MATCHER_COLS 

Definition at line 58 of file import-match-picker.c.


Function Documentation

GdkPixbuf * gen_probability_pixbuf ( gint  score,
GNCImportSettings settings,
GtkWidget *  widget 
)

This function generates a new pixmap representing a match score. It is a series of vertical bars of different colors. -Below or at the add_threshold the bars are red -Above or at the clear_threshold the bars are green -Between the two threshold the bars are yellow

Parameters:
score The score for which to generate a pixmap.
settings The user settings from which to get the threshold
widget The parent widget in which the pixmap will eventually be added. Will be used to generate the colormap.

Definition at line 262 of file import-backend.c.

00263 {
00264   GdkPixbuf* retval = NULL;
00265   gint i, j;
00266   gint score;
00267   const gint height = 15;
00268   const gint width_each_bar = 7;
00269   gchar * green_bar = ("bggggb ");
00270   gchar * yellow_bar = ("byyyyb ");
00271   gchar * red_bar = ("brrrrb ");
00272   gchar * black_bar = ("bbbbbb ");
00273   const gint width_first_bar = 1;
00274   gchar * black_first_bar = ("b");
00275   const gint num_colors = 5;
00276   gchar * size_str;
00277   gchar * none_color_str = g_strdup_printf("  c None");
00278   gchar * green_color_str = g_strdup_printf("g c green");
00279   gchar * yellow_color_str = g_strdup_printf("y c yellow");
00280   gchar * red_color_str = g_strdup_printf("r c red");
00281   gchar * black_color_str = g_strdup_printf("b c black");
00282   gchar * xpm[2+num_colors+height];
00283   gint add_threshold, clear_threshold;
00284 
00285   g_assert(settings);
00286   g_assert(widget);
00287   if (score_original < 0)
00288     {
00289       score = 0;
00290     }
00291   else
00292     {
00293       score=score_original;
00294     }
00295   size_str = g_strdup_printf("%d%s%d%s%d%s",(width_each_bar*score)+width_first_bar/*width*/," ",height," ",num_colors," 1"/*characters per pixel*/);
00296 
00297   /*DEBUG("Begin");*/
00298   xpm[0]=size_str;
00299   xpm[1]=none_color_str;
00300   xpm[2]=green_color_str;
00301   xpm[3]=yellow_color_str;
00302   xpm[4]=red_color_str; 
00303   xpm[5]=black_color_str;
00304   add_threshold = gnc_import_Settings_get_add_threshold(settings);
00305   clear_threshold = gnc_import_Settings_get_clear_threshold(settings);
00306 
00307   for(i=0;i<height;i++)
00308     {
00309       xpm[num_colors+1+i]= g_new0(char,(width_each_bar*score)+width_first_bar+1);
00310       for(j=0;j<=score;j++)
00311         {
00312           if(i==0||i==height-1)
00313             {
00314               if (j==0)
00315                 {
00316                   strcat(xpm[num_colors+1+i],black_first_bar);
00317                 }
00318               else
00319                 {
00320               strcat(xpm[num_colors+1+i],black_bar);
00321                 }
00322             }
00323           else
00324             {
00325               if (j==0)
00326                 {
00327                   strcat(xpm[num_colors+1+i],black_first_bar);
00328                 }
00329               else if (j <= add_threshold)
00330                 {
00331                   strcat(xpm[num_colors+1+i],red_bar);
00332                 }
00333               else if (j >= clear_threshold)
00334                 {
00335                   strcat(xpm[num_colors+1+i],green_bar);
00336                 }
00337               else
00338                 {
00339                   strcat(xpm[num_colors+1+i],yellow_bar);
00340                 }
00341             }
00342         }
00343     }  
00344   
00345   retval =  gdk_pixbuf_new_from_xpm_data((const gchar **)xpm);
00346   for(i=0;i<=num_colors+height;i++)
00347     { 
00348       /*DEBUG("free_loop i=%d%s%s",i,": ",xpm[i]);*/
00349       g_free(xpm[i]);
00350     }
00351   
00352   return retval;
00353 }

void gnc_file_aqbanking_import ( const gchar *  aqbanking_importername,
const gchar *  aqbanking_formatname,
gboolean  exec_as_aqbanking_jobs 
)

This routine will pop up a standard file selection dialog asking the user to pick a file to import. This file will be opened and read. Its contents will be imported into the current book, using the import matcher from import-main-matcher.h.

Parameters:
aqbanking_importername The aqbanking importer module that should be used. Possible values: "dtaus", "csv", "swift", or more.
aqbanking_formatname In aqbanking, each importer has one or more data formats available which define the actual data fields that should be used. In aqbanking, such a different format is called a "profile". Possible values for swift: "swift-mt940" or "swift-mt942", but for all others: "default", or more precisely: Look into $datadir/aqbanking/imexporters and look into the "name" field of the foo.conf files.
exec_as_aqbanking_jobs If TRUE, additionally queue the imported transactions as online jobs over aqbanking/HBCI. If FALSE, just import the transactions and that's it.

Definition at line 65 of file gnc-file-aqb-import.c.

00068 {
00069   char *selected_filename;
00070   char *default_dir;
00071   int dtaus_fd;
00072 
00073   DEBUG("gnc_file_dtaus_import(): Begin...\n");
00074 
00075   default_dir = gnc_get_default_directory(GCONF_SECTION);
00076   selected_filename = gnc_file_dialog(_("Select a file to import"),
00077                                       NULL,
00078                                       default_dir,
00079                                       GNC_FILE_DIALOG_IMPORT);
00080   g_free(default_dir);
00081 
00082   if(selected_filename!=NULL) {
00083     /* Remember the directory as the default. */
00084     default_dir = g_path_get_dirname(selected_filename);
00085     gnc_set_default_directory(GCONF_SECTION, default_dir);
00086     g_free(default_dir);
00087 
00088     /*strncpy(file,selected_filename, 255);*/
00089     DEBUG("Filename found: %s",selected_filename);
00090 
00091     DEBUG("Opening selected file");
00092     dtaus_fd = g_open(selected_filename, O_RDONLY, 0);
00093     if (dtaus_fd == -1) {
00094       DEBUG("Could not open file %s", selected_filename);
00095       return;
00096     }
00097     g_free(selected_filename);
00098 
00099     {
00100       int result;
00101       AB_BANKING *ab;
00102       AB_IMEXPORTER *importer;
00103       AB_IMEXPORTER_CONTEXT *ctx=0;
00104       GWEN_BUFFEREDIO *buffio;
00105       GWEN_DB_NODE *dbProfiles;
00106       GWEN_DB_NODE *dbProfile;
00107       GNCInteractor *interactor = NULL;
00108       const char *importerName = aqbanking_importername;
00109       const char *profileName = aqbanking_profilename;
00110 
00111       /* Get API */
00112       ab = gnc_AB_BANKING_new_currentbook (NULL, &interactor);
00113       if (ab == NULL) {
00114         g_message("gnc_file_dtaus_import: Couldn't get HBCI API. Nothing will happen.\n");
00115         return;
00116       }
00117       g_assert (interactor);
00118 
00119       /* get import module */
00120       importer=AB_Banking_GetImExporter(ab, importerName);
00121       if (!importer) {
00122         DEBUG("Import module %s not found", importerName);
00123         gnc_error_dialog(NULL, "%s",("Import module for DTAUS import not found."));
00124         return;
00125       }
00126       g_assert(importer);
00127 
00128       /* load the import profile */
00129       dbProfiles=AB_Banking_GetImExporterProfiles(ab, importerName);
00130 
00131       /* select profile */
00132       dbProfile=GWEN_DB_GetFirstGroup(dbProfiles);
00133       while(dbProfile) {
00134         const char *name;
00135 
00136         name=GWEN_DB_GetCharValue(dbProfile, "name", 0, 0);
00137         g_assert(name);
00138         if (strcasecmp(name, profileName)==0)
00139           break;
00140         dbProfile=GWEN_DB_GetNextGroup(dbProfile);
00141       }
00142       if (!dbProfile) {
00143         g_warning("Profile \"%s\" for importer \"%s\" not found\n",
00144               profileName, importerName);
00145         /* For debugging: Print those available names that have been found. */
00146         dbProfile=GWEN_DB_GetFirstGroup(dbProfiles);
00147         while(dbProfile) {
00148           const char *name;
00149           name=GWEN_DB_GetCharValue(dbProfile, "name", 0, 0);
00150           g_assert(name);
00151           g_warning("Only found profile \"%s\"\n", name);
00152           dbProfile=GWEN_DB_GetNextGroup(dbProfile);
00153         }
00154         return;
00155       }
00156       g_assert(dbProfile);
00157 
00158       /* import new context */
00159       ctx=AB_ImExporterContext_new();
00160       g_assert(ctx);
00161 
00162       /* Wrap file in gwen_bufferedio */
00163       buffio = GWEN_BufferedIO_File_new(dtaus_fd);
00164       g_assert(buffio);
00165       GWEN_BufferedIO_SetReadBuffer(buffio, 0, 1024);
00166 
00167       result = AB_ImExporter_Import(importer,
00168                                   ctx,
00169                                   buffio,
00170                                   dbProfile);
00171 
00172       DEBUG("Parsing result: %d\n", result);
00173 
00174       GWEN_BufferedIO_Close(buffio);
00175       GWEN_BufferedIO_free(buffio);
00176       GWEN_DB_Group_free(dbProfiles);
00177 
00178       {
00179         /* Now get all accountinfos */
00180         GNCImportMainMatcher *importer_generic_gui;
00181         GtkWidget *parent = NULL;
00182         gboolean successful = FALSE;
00183         GList *ab_job_list;
00184 
00185         /* Create importer GUI */
00186         importer_generic_gui = gnc_gen_trans_list_new(parent, NULL, TRUE, 14);
00187 
00188         /* Import the transactions from the ctx into gnucash. */
00189         ab_job_list = gnc_hbci_import_ctx(ab, ctx, importer_generic_gui,
00190                                           execute_transactions);
00191         /* Finished importing. */
00192 
00193         /* We clean up here. */
00194         AB_ImExporterContext_free(ctx);
00195 
00196         if (execute_transactions) {
00197           /* Wait for the gnucash importer to be finished (it is being
00198              run anyway). */
00199           result = gnc_gen_trans_list_run (importer_generic_gui);
00200 
00201           if (result)
00202             /* Execute these jobs now. This function already delete()s the
00203                job. */
00204             /* no parent so far; otherwise add this: GNCInteractor_reparent (interactor, parent); */
00205             successful = gnc_hbci_multijob_execute (parent, ab, ab_job_list, interactor);
00206           /* else */
00207           
00208           /* Delete all jobs from queue in any case. */
00209           gnc_hbci_clearqueue (ab, ab_job_list);
00210         }
00211         else {
00212           successful = TRUE;
00213         }
00214 
00215         if (successful) {
00216           /* If execution was not successful, leave the log window
00217              still intact and open. */
00218           gnc_AB_BANKING_fini (ab);
00219           gnc_AB_BANKING_delete (ab);
00220         }
00221       }
00222     }
00223   }
00224 }

void gnc_file_log_replay ( void   ) 

The gnc_file_log_replay() routine will pop up a standard file selection dialogue asking the user to pick a log file to replay. If one is selected the the .log file is opened and read. It's contents are then silently merged in the current log file.

Definition at line 495 of file gnc-log-replay.c.

00496 {
00497   char *selected_filename;
00498   char *default_dir;
00499   char read_buf[256];
00500   char *read_retval;
00501   GtkFileFilter *filter;
00502   FILE *log_file;
00503   char * record_start_str = "===== START";
00504   /* NOTE: This string must match src/engine/TransLog.c (sans newline) */
00505   char * expected_header_orig = "mod\ttrans_guid\tsplit_guid\ttime_now\t"
00506         "date_entered\tdate_posted\tacc_guid\tacc_name\tnum\tdescription\t"
00507         "notes\tmemo\taction\treconciled\tamount\tvalue\tdate_reconciled";
00508   static char *expected_header = NULL;
00509 
00510   /* Use g_strdup_printf so we don't get accidental tab -> space conversion */
00511   if (!expected_header)
00512     expected_header = g_strdup_printf(expected_header_orig);
00513 
00514   qof_log_set_level(GNC_MOD_IMPORT, QOF_LOG_DEBUG);
00515   ENTER(" ");
00516 
00517   default_dir = gnc_get_default_directory(GCONF_SECTION);
00518 
00519   filter = gtk_file_filter_new();
00520   gtk_file_filter_set_name(filter, "*.log");
00521   gtk_file_filter_add_pattern(filter, "*.[Ll][Oo][Gg]");
00522   selected_filename = gnc_file_dialog(_("Select a .log file to replay"),
00523                                       g_list_prepend(NULL, filter),
00524                                       default_dir,
00525                                       GNC_FILE_DIALOG_OPEN);
00526   g_free(default_dir);
00527 
00528   if(selected_filename!=NULL)
00529     {
00530       /* Remember the directory as the default. */
00531       default_dir = g_path_get_dirname(selected_filename);
00532       gnc_set_default_directory(GCONF_SECTION, default_dir);
00533       g_free(default_dir);
00534 
00535       /*strncpy(file,selected_filename, 255);*/
00536       DEBUG("Filename found: %s",selected_filename);
00537       if (xaccFileIsCurrentLog(selected_filename)) {
00538         g_warning("Cannot open the current log file: %s", selected_filename);
00539         gnc_error_dialog(NULL,
00540                          /* Translators: %s is the file name. */
00541                          _("Cannot open the current log file: %s"),
00542                          selected_filename);
00543       } else {
00544         DEBUG("Opening selected file");
00545         log_file = g_fopen(selected_filename, "r");
00546         if(!log_file || ferror(log_file)!=0) {
00547           int err = errno;
00548           perror("File open failed");
00549           gnc_error_dialog(NULL,
00550                            /* Translation note:
00551                             * First argument is the filename,
00552                             * second argument is the error.
00553                             */
00554                            _("Failed to open log file: %s: %s"),
00555                            selected_filename,
00556                            strerror(err));
00557         } else {
00558           if((read_retval = fgets(read_buf,sizeof(read_buf),log_file)) == NULL) {
00559               DEBUG("Read error or EOF");
00560               gnc_info_dialog(NULL, "%s",
00561                               _("The log file you selected was empty."));
00562           } else {
00563             if(strncmp(expected_header,read_buf,strlen(expected_header))!=0) {
00564                 PERR("File header not recognised:\n%s",read_buf);
00565                 PERR("Expected:\n%s",expected_header);
00566                 gnc_error_dialog(NULL, "%s",
00567                                  _("The log file you selected cannot be read.  "
00568                                    "The file header was not recognized."));
00569             } else {
00570               do {
00571                 read_retval = fgets(read_buf,sizeof(read_buf),log_file);
00572                 /*DEBUG("Chunk read: %s",read_retval);*/
00573                 if(strncmp(record_start_str,read_buf,strlen(record_start_str))==0) {/* If a record started */
00574                   process_trans_record(log_file);
00575                 }
00576               }while(feof(log_file)==0);
00577             }
00578           }
00579           fclose(log_file);
00580         }
00581       }
00582       g_free(selected_filename);
00583     }
00584   LEAVE("");
00585 }

void gnc_file_ofx_import ( void   ) 

The gnc_file_ofx_import() routine will pop up a standard file selection dialogue asking the user to pick a OFX/QFX file. If one is selected the the OFX file is opened and read. It's contents are merged into the existing session (if any). The current session continues to remain open for editing.

Definition at line 635 of file gnc-ofx-import.c.

00636 {
00637   extern int ofx_PARSER_msg;
00638   extern int ofx_DEBUG_msg;
00639   extern int ofx_WARNING_msg;
00640   extern int ofx_ERROR_msg;
00641   extern int ofx_INFO_msg;
00642   extern int ofx_STATUS_msg;
00643   char *selected_filename;
00644   char *default_dir;
00645   LibofxContextPtr libofx_context = libofx_get_new_context();
00646 
00647   ofx_PARSER_msg = false;
00648   ofx_DEBUG_msg = false;
00649   ofx_WARNING_msg = true;
00650   ofx_ERROR_msg = true;
00651   ofx_INFO_msg = true;
00652   ofx_STATUS_msg = false;
00653 
00654   DEBUG("gnc_file_ofx_import(): Begin...\n");
00655 
00656   default_dir = gnc_get_default_directory(GCONF_SECTION);
00657   selected_filename = gnc_file_dialog(_("Select an OFX/QFX file to process"),
00658                                       NULL,
00659                                       default_dir,
00660                                       GNC_FILE_DIALOG_IMPORT);
00661   g_free(default_dir);
00662 
00663   if(selected_filename!=NULL)