Example #1
0
int test1(int argc, char **argv) {
  GWEN_GUI *gui;
  int rv;
  GWEN_DIALOG *dlg;

  rv=GWEN_Init();
  if (rv) {
    DBG_ERROR_ERR(0, rv);
    return 2;
  }

  GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Info);

  gtk_set_locale ();
  gtk_init (&argc, &argv);

  /* create GUI */
  gui=Gtk2_Gui_new();
  GWEN_Gui_SetGui(gui);

  dlg=Dlg_Test1_new();
  if (dlg==NULL) {
    fprintf(stderr, "Could not create dialog.\n");
    return 2;
  }

  rv=GWEN_Gui_ExecDialog(dlg, 0);
  fprintf(stderr, "Result: %d\n", rv);

  return 0;
}
Example #2
0
int AB_SetupDialog_EditUser(GWEN_DIALOG *dlg)
{
  AB_SETUP_DIALOG *xdlg;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AB_SETUP_DIALOG, dlg);
  assert(xdlg);

  if (xdlg->currentUserList) {
    uint32_t uid;

    uid=AB_SetupDialog_GetCurrentUserId(dlg);
    if (uid) {
      AB_USER *u;

      u=AB_User_List_GetByUniqueId(xdlg->currentUserList, uid);
      if (u) {
        AB_PROVIDER *pro;
        uint32_t flags=0;
        GWEN_DIALOG *dlg2;
        int rv;

        pro=AB_User_GetProvider(u);
        assert(pro);

        /* get EditUser dialog */
        flags=AB_Provider_GetFlags(pro);
        if (flags & AB_PROVIDER_FLAGS_HAS_EDITUSER_DIALOG) {
          DBG_ERROR(AQBANKING_LOGDOMAIN, "Letting backend \"%s\" create dialog", AB_Provider_GetName(pro));
          dlg2=AB_Provider_GetEditUserDialog(pro, u);
        }
        else {
          DBG_ERROR(AQBANKING_LOGDOMAIN, "Letting AqBanking create dialog");
          dlg2=AB_EditUserDialog_new(pro, u, 1);
        }
        if (dlg2==NULL) {
          DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not create dialog");
          return GWEN_DialogEvent_ResultHandled;
        }

        rv=GWEN_Gui_ExecDialog(dlg2, 0);
        if (rv==0) {
          /* rejected */
          GWEN_Dialog_free(dlg2);
          return GWEN_DialogEvent_ResultHandled;
        }
        GWEN_Dialog_free(dlg2);

        /* reload */
        AB_SetupDialog_Reload(dlg);
      } /* if u */
    } /* if uid */
    else {
      DBG_ERROR(AQBANKING_LOGDOMAIN, "No current user");
    }
  } /* if xdlg->currentUserList */
  return GWEN_DialogEvent_ResultHandled;
}
Example #3
0
int AO_NewUserDialog_HandleActivatedSpecial(GWEN_DIALOG *dlg)
{
  AO_NEWUSER_DIALOG *xdlg;
  GWEN_DIALOG *dlg2;
  int rv;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AO_NEWUSER_DIALOG, dlg);
  assert(xdlg);

  dlg2=AO_OfxSpecialDialog_new(xdlg->provider);
  if (dlg2==NULL) {
    DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not create dialog");
    return GWEN_DialogEvent_ResultHandled;
  }

  AO_OfxSpecialDialog_SetHttpVersion(dlg2, xdlg->httpVMajor, xdlg->httpVMinor);
  AO_OfxSpecialDialog_SetFlags(dlg2, xdlg->flags);

  AO_OfxSpecialDialog_SetClientUid(dlg2, xdlg->clientUid);
  AO_OfxSpecialDialog_SetSecurityType(dlg2, xdlg->securityType);

  rv=GWEN_Gui_ExecDialog(dlg2, 0);
  if (rv==0) {
    /* rejected */
    DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "Rejected");
    GWEN_Dialog_free(dlg2);
    return GWEN_DialogEvent_ResultHandled;
  }
  else {
    const char *s;

    DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "Accepted");
    xdlg->httpVMajor=AO_OfxSpecialDialog_GetHttpVMajor(dlg2);
    xdlg->httpVMinor=AO_OfxSpecialDialog_GetHttpVMinor(dlg2);
    xdlg->flags=AO_OfxSpecialDialog_GetFlags(dlg2);

    s=AO_OfxSpecialDialog_GetClientUid(dlg2);
    free(xdlg->clientUid);
    if (s)
      xdlg->clientUid=strdup(s);
    else
      xdlg->clientUid=NULL;

    s=AO_OfxSpecialDialog_GetSecurityType(dlg2);
    free(xdlg->securityType);
    if (s)
      xdlg->securityType=strdup(s);
    else
      xdlg->securityType=NULL;
  }

  GWEN_Dialog_free(dlg2);
  return GWEN_DialogEvent_ResultHandled;
}
Example #4
0
int AB_SetupDialog_EditAccount(GWEN_DIALOG *dlg)
{
  AB_SETUP_DIALOG *xdlg;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AB_SETUP_DIALOG, dlg);
  assert(xdlg);

  if (xdlg->currentAccountList) {
    uint32_t aid;

    aid=AB_SetupDialog_GetCurrentAccountId(dlg);
    if (aid) {
      AB_ACCOUNT *a;

      a=AB_Account_List_GetByUniqueId(xdlg->currentAccountList, aid);
      if (a) {
        AB_PROVIDER *pro;
        uint32_t flags=0;
        GWEN_DIALOG *dlg2;
        int rv;

        pro=AB_Account_GetProvider(a);
        assert(pro);
        flags=AB_Provider_GetFlags(pro);
        if (flags & AB_PROVIDER_FLAGS_HAS_EDITACCOUNT_DIALOG)
          dlg2=AB_Provider_GetEditAccountDialog(pro, a);
        else
          dlg2=AB_EditAccountDialog_new(pro, a, 1);
        if (dlg2==NULL) {
          DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not create dialog");
          return GWEN_DialogEvent_ResultHandled;
        }

        rv=GWEN_Gui_ExecDialog(dlg2, 0);
        if (rv==0) {
          /* rejected */
          GWEN_Dialog_free(dlg2);
          return GWEN_DialogEvent_ResultHandled;
        }
        GWEN_Dialog_free(dlg2);
        AB_SetupDialog_Reload(dlg);
      } /* if a */
    } /* if aid */
    else {
      DBG_ERROR(AQBANKING_LOGDOMAIN, "No current account");
    }
  } /* if xdlg->currentAccountList */
  return GWEN_DialogEvent_ResultHandled;
}
Example #5
0
int APY_NewUserDialog_HandleActivatedSpecial(GWEN_DIALOG *dlg) {
#if 0
  APY_NEWUSER_DIALOG *xdlg;
  GWEN_DIALOG *dlg2;
  int rv;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, APY_NEWUSER_DIALOG, dlg);
  assert(xdlg);

  dlg2=AH_PinTanSpecialDialog_new(xdlg->banking);
  if (dlg2==NULL) {
    DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not create dialog");
    return GWEN_DialogEvent_ResultHandled;
  }

  AH_PinTanSpecialDialog_SetHttpVersion(dlg2, xdlg->httpVMajor, xdlg->httpVMinor);
  AH_PinTanSpecialDialog_SetHbciVersion(dlg2, xdlg->hbciVersion);
  AH_PinTanSpecialDialog_SetFlags(dlg2, xdlg->flags);

  rv=GWEN_Gui_ExecDialog(dlg2, 0);
  if (rv==0) {
    /* rejected */
    GWEN_Dialog_free(dlg2);
    return GWEN_DialogEvent_ResultHandled;
  }
  else {
    xdlg->httpVMajor=AH_PinTanSpecialDialog_GetHttpVMajor(dlg2);
    xdlg->httpVMinor=AH_PinTanSpecialDialog_GetHttpVMinor(dlg2);
    xdlg->hbciVersion=AH_PinTanSpecialDialog_GetHbciVersion(dlg2);
    xdlg->flags=AH_PinTanSpecialDialog_GetFlags(dlg2);
  }

  GWEN_Dialog_free(dlg2);
#endif
  return GWEN_DialogEvent_ResultHandled;
}
Example #6
0
int AH_NewKeyFileDialog_HandleActivatedSpecial(GWEN_DIALOG *dlg) {
  AH_NEWKEYFILE_DIALOG *xdlg;
  GWEN_DIALOG *dlg2;
  int rv;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_NEWKEYFILE_DIALOG, dlg);
  assert(xdlg);

  dlg2=AH_RdhSpecialDialog_new(xdlg->banking);
  if (dlg2==NULL) {
    DBG_ERROR(AQHBCI_LOGDOMAIN, "Could not create dialog");
    GWEN_Gui_ShowError(I18N("Error"), "%s", I18N("Could not create dialog, maybe an installation error?"));
    return GWEN_DialogEvent_ResultHandled;
  }

  AH_RdhSpecialDialog_SetFlags(dlg2, xdlg->flags);
  AH_RdhSpecialDialog_SetHbciVersion(dlg2, xdlg->hbciVersion);
  AH_RdhSpecialDialog_SetRdhVersion(dlg2, xdlg->rdhVersion);

  rv=GWEN_Gui_ExecDialog(dlg2, 0);
  if (rv==0) {
    /* rejected */
    GWEN_Dialog_free(dlg2);
    return GWEN_DialogEvent_ResultHandled;
  }
  else {
    xdlg->hbciVersion=AH_RdhSpecialDialog_GetHbciVersion(dlg2);
    xdlg->rdhVersion=AH_RdhSpecialDialog_GetRdhVersion(dlg2);
    xdlg->flags=AH_RdhSpecialDialog_GetFlags(dlg2);
  }

  GWEN_Dialog_free(dlg2);

  return GWEN_DialogEvent_ResultHandled;
}
Example #7
0
int AH_NewKeyFileDialog_HandleActivatedBankCode(GWEN_DIALOG *dlg) {
  AH_NEWKEYFILE_DIALOG *xdlg;
  GWEN_DIALOG *dlg2;
  int rv;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AH_NEWKEYFILE_DIALOG, dlg);
  assert(xdlg);

  dlg2=AB_SelectBankInfoDialog_new(xdlg->banking, "de", NULL);
  if (dlg2==NULL) {
    DBG_ERROR(AQHBCI_LOGDOMAIN, "Could not create dialog");
    GWEN_Gui_ShowError(I18N("Error"), "%s", I18N("Could not create dialog, maybe an installation error?"));
    return GWEN_DialogEvent_ResultHandled;
  }

  rv=GWEN_Gui_ExecDialog(dlg2, 0);
  if (rv==0) {
    /* rejected */
    GWEN_Dialog_free(dlg2);
    return GWEN_DialogEvent_ResultHandled;
  }
  else {
    const AB_BANKINFO *bi;

    bi=AB_SelectBankInfoDialog_GetSelectedBankInfo(dlg2);
    if (bi) {
      const char *s;
      AB_BANKINFO_SERVICE *sv;

      s=AB_BankInfo_GetBankId(bi);
      GWEN_Dialog_SetCharProperty(dlg,
				  "wiz_bankcode_edit",
				  GWEN_DialogProperty_Value,
				  0,
				  (s && *s)?s:"",
				  0);

      s=AB_BankInfo_GetBankName(bi);
      GWEN_Dialog_SetCharProperty(dlg,
				  "wiz_bankname_edit",
				  GWEN_DialogProperty_Value,
				  0,
				  (s && *s)?s:"",
				  0);
      sv=AB_BankInfoService_List_First(AB_BankInfo_GetServices(bi));
      while(sv) {
	const char *s;

	s=AB_BankInfoService_GetType(sv);
	if (s && *s && strcasecmp(s, "HBCI")==0) {
	  s=AB_BankInfoService_GetMode(sv);
	  if (s && *s && strncasecmp(s, "RDH", 3)==0)
	    break;
	}
	sv=AB_BankInfoService_List_Next(sv);
      }

      if (sv) {
	/* RDH service found */
	s=AB_BankInfoService_GetMode(sv);
	if (s && *s) {
	  if (strcasecmp(s, "RDH1")==0)
	    xdlg->rdhVersion=1;
	  else if (strcasecmp(s, "RDH2")==0)
	    xdlg->rdhVersion=2;
	  else if (strcasecmp(s, "RDH3")==0)
	    xdlg->rdhVersion=3;
	  else if (strcasecmp(s, "RDH4")==0)
	    xdlg->rdhVersion=4;
	  else if (strcasecmp(s, "RDH5")==0)
	    xdlg->rdhVersion=5;
	  else if (strcasecmp(s, "RDH6")==0)
	    xdlg->rdhVersion=6;
	  else if (strcasecmp(s, "RDH7")==0)
	    xdlg->rdhVersion=7;
	  else if (strcasecmp(s, "RDH8")==0)
	    xdlg->rdhVersion=8;
	  else if (strcasecmp(s, "RDH9")==0)
	    xdlg->rdhVersion=9;
	  else if (strcasecmp(s, "RDH10")==0)
	    xdlg->rdhVersion=10;
	  else if (strcasecmp(s, "RDH")==0)
	    xdlg->rdhVersion=1;
	}

	s=AB_BankInfoService_GetAddress(sv);
	GWEN_Dialog_SetCharProperty(dlg,
				    "wiz_url_edit",
				    GWEN_DialogProperty_Value,
				    0,
				    (s && *s)?s:"",
				    0);
	s=AB_BankInfoService_GetPversion(sv);
	if (s && *s) {
	  if (strcasecmp(s, "2.01")==0 ||
	      strcasecmp(s, "2")==0)
	    xdlg->hbciVersion=201;
	  else if (strcasecmp(s, "2.10")==0 ||
		   strcasecmp(s, "2.1")==0)
	    xdlg->hbciVersion=210;
	  else if (strcasecmp(s, "2.20")==0 ||
		   strcasecmp(s, "2.2")==0)
	    xdlg->hbciVersion=220;
	  else if (strcasecmp(s, "3.00")==0 ||
		   strcasecmp(s, "3.0")==0 ||
		   strcasecmp(s, "3")==0)
	    xdlg->hbciVersion=300;
	  else if (strcasecmp(s, "4.00")==0 ||
		   strcasecmp(s, "4.0")==0 ||
		   strcasecmp(s, "4")==0)
	    xdlg->hbciVersion=400;
	}
      }
    }
  }

  GWEN_Dialog_free(dlg2);

  if (AH_NewKeyFileDialog_GetBankPageData(dlg)<0)
    GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
  else
    GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);

  return GWEN_DialogEvent_ResultHandled;
}
Example #8
0
int AO_NewUserDialog_HandleActivatedBankSelect(GWEN_DIALOG *dlg)
{
  AO_NEWUSER_DIALOG *xdlg;
  int rv;
  GWEN_DIALOG *dlg2;
  GWEN_BUFFER *tbuf;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AO_NEWUSER_DIALOG, dlg);
  assert(xdlg);

  /* get data dir */
  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
  rv=AB_Banking_GetProviderUserDataDir(xdlg->banking, "aqofxconnect", tbuf);
  if (rv<0) {
    DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "here (%d)", rv);
    GWEN_Buffer_free(tbuf);
    return GWEN_DialogEvent_ResultHandled;
  }
  GWEN_Buffer_AppendString(tbuf, GWEN_DIR_SEPARATOR_S "ofxhome");

  /* possibly create data folder */
  rv=GWEN_Directory_GetPath(GWEN_Buffer_GetStart(tbuf), GWEN_PATH_FLAGS_CHECKROOT);
  if (rv<0) {
    DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "here (%d)", rv);
    GWEN_Buffer_free(tbuf);
    return GWEN_DialogEvent_ResultHandled;
  }

  dlg2=OH_GetInstituteDialog_new(GWEN_Buffer_GetStart(tbuf), NULL);
  GWEN_Buffer_free(tbuf);
  if (dlg2==NULL) {
    DBG_INFO(AQOFXCONNECT_LOGDOMAIN, "Could not create dialog");
    return GWEN_DialogEvent_ResultHandled;
  }
  rv=GWEN_Gui_ExecDialog(dlg2, 0);
  if (rv<=0) {
    DBG_DEBUG(AQOFXCONNECT_LOGDOMAIN, "Dialog: rejected (%d)", rv);
    return GWEN_DialogEvent_ResultHandled;
  }
  else {
    const OH_INSTITUTE_DATA *od;

    DBG_DEBUG(AQOFXCONNECT_LOGDOMAIN, "Dialog: rejected (%d)", rv);
    od=OH_GetInstituteDialog_GetSelectedInstitute(dlg2);
    if (od) {
      const char *s;

      s=OH_InstituteData_GetName(od);
      if (s && *s)
        GWEN_Dialog_SetCharProperty(dlg, "wiz_bankname_edit", GWEN_DialogProperty_Value, 0, s, 0);

      s=OH_InstituteData_GetFid(od);
      if (s && *s)
        GWEN_Dialog_SetCharProperty(dlg, "wiz_fid_edit", GWEN_DialogProperty_Value, 0, s, 0);
      s=OH_InstituteData_GetOrg(od);
      if (s && *s)
        GWEN_Dialog_SetCharProperty(dlg, "wiz_org_edit", GWEN_DialogProperty_Value, 0, s, 0);
      s=OH_InstituteData_GetUrl(od);
      if (s && *s)
        GWEN_Dialog_SetCharProperty(dlg, "wiz_url_edit", GWEN_DialogProperty_Value, 0, s, 0);
      rv=AO_NewUserDialog_GetBankPageData(dlg);
      if (rv<0)
        GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 0, 0);
      else
        GWEN_Dialog_SetIntProperty(dlg, "wiz_next_button", GWEN_DialogProperty_Enabled, 0, 1, 0);
    }
  }
  GWEN_Dialog_free(dlg2);
  return GWEN_DialogEvent_ResultHandled;
}
Example #9
0
int AB_SetupDialog_AddUser(GWEN_DIALOG *dlg)
{
  AB_SETUP_DIALOG *xdlg;
  GWEN_DIALOG *dlg2;
  int rv;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AB_SETUP_DIALOG, dlg);
  assert(xdlg);

  dlg2=AB_SetupNewUserDialog_new(xdlg->banking);
  if (dlg2==NULL) {
    DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not create dialog");
    return GWEN_DialogEvent_ResultHandled;
  }

  rv=GWEN_Gui_ExecDialog(dlg2, 0);
  if (rv==0) {
    /* rejected */
    GWEN_Dialog_free(dlg2);
  }
  else {
    const char *s;

    s=AB_SetupNewUserDialog_GetSelectedBackend(dlg2);
    if (s && *s) {
      AB_PROVIDER *pro;
      int selectedType;
      uint32_t flags;

      pro=AB_SetupDialog_GetProviderByName(dlg, s);
      if (pro==NULL) {
        DBG_ERROR(AQBANKING_LOGDOMAIN, "Provider [%s] not found", s);
        GWEN_Dialog_free(dlg2);
        return GWEN_DialogEvent_ResultHandled;
      }
      selectedType=AB_SetupNewUserDialog_GetSelectedType(dlg2);
      GWEN_Dialog_free(dlg2);

      flags=AB_Provider_GetFlags(pro);
      if (flags & AB_PROVIDER_FLAGS_HAS_NEWUSER_DIALOG) {
        GWEN_DIALOG *dlg3;
        int rv;

        dlg3=AB_Provider_GetNewUserDialog(pro, selectedType);
        if (dlg3==NULL) {
          DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not create dialog");
          return GWEN_DialogEvent_ResultHandled;
        }

        rv=GWEN_Gui_ExecDialog(dlg3, 0);
        if (rv==0) {
          /* rejected */
          GWEN_Dialog_free(dlg3);
          return GWEN_DialogEvent_ResultHandled;
        }
        GWEN_Dialog_free(dlg3);
        AB_SetupDialog_Reload(dlg);
      }
      else {
        GWEN_DIALOG *dlg3;
        AB_USER *u;
        const char *s;
        int rv;

        u=AB_Provider_CreateUserObject(pro);
        if (u==NULL) {
          DBG_INFO(AQBANKING_LOGDOMAIN, "No user created.");
          return GWEN_DialogEvent_ResultHandled;
        }

        s=GWEN_I18N_GetCurrentLocale();
        if (s && *s) {
          if (strstr(s, "de_"))
            AB_User_SetCountry(u, "de");
          else if (strstr(s, "us_"))
            AB_User_SetCountry(u, "us");
        }

        dlg3=AB_EditUserDialog_new(pro, u, 0);
        if (dlg3==NULL) {
          DBG_INFO(AQBANKING_LOGDOMAIN, "Could not create dialog");
          AB_User_free(u);
          return GWEN_DialogEvent_ResultHandled;
        }

        rv=GWEN_Gui_ExecDialog(dlg3, 0);
        if (rv==0) {
          /* rejected */
          GWEN_Dialog_free(dlg3);
          AB_User_free(u);
          return GWEN_DialogEvent_ResultHandled;
        }
        GWEN_Dialog_free(dlg3);

        rv=AB_Provider_AddUser(pro, u);
        if (rv<0) {
          DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
          AB_User_free(u);
          return GWEN_DialogEvent_ResultHandled;
        }
        AB_User_free(u);

        AB_SetupDialog_Reload(dlg);
      }
    }
    else {
      GWEN_Dialog_free(dlg2);
      return GWEN_DialogEvent_ResultHandled;
    }
  }

  return GWEN_DialogEvent_ResultHandled;
}
Example #10
0
int AB_SetupDialog_AddAccount(GWEN_DIALOG *dlg)
{
  AB_SETUP_DIALOG *xdlg;
  AB_PROVIDER *pro;
  const char *s;
  const char *initialProvider=NULL;
  uint32_t flags;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, AB_SETUP_DIALOG, dlg);
  assert(xdlg);

  s=GWEN_I18N_GetCurrentLocale();
  if (s && *s) {
    if (strstr(s, "de_"))
      initialProvider="aqhbci";
    else
      initialProvider="aqofxconnect";
  }
  pro=AB_SelectBackend(xdlg->banking,
                       initialProvider,
                       I18N("Please select the online banking backend the new "
                            "account is to be created for."));
  if (pro==NULL) {
    DBG_ERROR(0, "No provider selected.");
    return GWEN_DialogEvent_ResultHandled;
  }

  flags=AB_Provider_GetFlags(pro);
  if (flags & AB_PROVIDER_FLAGS_HAS_NEWACCOUNT_DIALOG) {
    GWEN_DIALOG *dlg2;
    int rv;

    dlg2=AB_Provider_GetNewAccountDialog(pro);
    if (dlg2==NULL) {
      DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not create dialog");
      return GWEN_DialogEvent_ResultHandled;
    }

    rv=GWEN_Gui_ExecDialog(dlg2, 0);
    if (rv==0) {
      /* rejected */
      GWEN_Dialog_free(dlg2);
      AB_Banking_EndUseProvider(xdlg->banking, pro);
      return GWEN_DialogEvent_ResultHandled;
    }
    GWEN_Dialog_free(dlg2);
    AB_Banking_EndUseProvider(xdlg->banking, pro);
    AB_SetupDialog_Reload(dlg);
  }
  else {
    GWEN_DIALOG *dlg2;
    AB_ACCOUNT *a;
    const char *s;
    int rv;

    a=AB_Provider_CreateAccountObject(pro);
    if (a==NULL) {
      DBG_INFO(AQBANKING_LOGDOMAIN, "No account created.");
      AB_Banking_EndUseProvider(xdlg->banking, pro);
      return GWEN_DialogEvent_ResultHandled;
    }

    s=GWEN_I18N_GetCurrentLocale();
    if (s && *s) {
      if (strstr(s, "de_")) {
        AB_Account_SetCountry(a, "de");
        AB_Account_SetCurrency(a, "EUR");
      }
      else if (strstr(s, "us_")) {
        AB_Account_SetCountry(a, "us");
        AB_Account_SetCurrency(a, "USD");
      }
    }

    dlg2=AB_EditAccountDialog_new(pro, a, 0);
    if (dlg2==NULL) {
      DBG_INFO(AQBANKING_LOGDOMAIN, "Could not create dialog");
      AB_Account_free(a);
      AB_Banking_EndUseProvider(xdlg->banking, pro);
      return GWEN_DialogEvent_ResultHandled;
    }

    rv=GWEN_Gui_ExecDialog(dlg2, 0);
    if (rv==0) {
      /* rejected */
      GWEN_Dialog_free(dlg2);
      AB_Account_free(a);
      AB_Banking_EndUseProvider(xdlg->banking, pro);
      return GWEN_DialogEvent_ResultHandled;
    }
    GWEN_Dialog_free(dlg2);

    rv=AB_Provider_AddAccount(pro, a, 1); /* do lock corresponding user */
    if (rv<0) {
      DBG_INFO(AQBANKING_LOGDOMAIN, "here (%d)", rv);
      AB_Account_free(a);
      return GWEN_DialogEvent_ResultHandled;
    }
    AB_Account_free(a);

    AB_Banking_EndUseProvider(xdlg->banking, pro);

    AB_SetupDialog_Reload(dlg);
  }

  return GWEN_DialogEvent_ResultHandled;
}
Example #11
0
int test3(int argc, char **argv) {
#ifdef USE_GWENGUI_GTK2
  GWEN_GUI *gui;
  GWEN_DIALOG *dlg;
  int rv;
  AB_BANKING *ab;

  rv=GWEN_Init();
  if (rv) {
    fprintf(stderr, "ERROR: Unable to init Gwen.\n");
    exit(2);
  }

  GWEN_Logger_SetLevel(AQBANKING_LOGDOMAIN, GWEN_LoggerLevel_Info);
  GWEN_Logger_SetLevel(AQOFXCONNECT_LOGDOMAIN, GWEN_LoggerLevel_Info);
  GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug);

  gtk_init(&argc, &argv);

  gui=Gtk2_Gui_new();
  GWEN_Gui_SetGui(gui);

  ab=AB_Banking_new("test-ofxhome", NULL, 0);
  rv=AB_Banking_Init(ab);
  if (rv<0){
    fprintf(stderr, "Error on banking init: %d\n", rv);
    exit(2);
  }
  AB_Gui_Extend(gui, ab);

  dlg=OH_GetInstituteDialog_new("/tmp/ofx", NULL);
  if (dlg==NULL) {
    fprintf(stderr, "Could not create dialog\n");
    exit(2);
  }
  rv=GWEN_Gui_ExecDialog(dlg, 0);
  if (rv<=0){
    fprintf(stderr, "Dialog was aborted/rejected\n");
  }
  else {
    const OH_INSTITUTE_DATA *od;

    fprintf(stderr, "Dialog accepted, all fine\n");
    od=OH_GetInstituteDialog_GetSelectedInstitute(dlg);
    if (od) {
      fprintf(stderr, "- Id  : %d\n", OH_InstituteData_GetId(od));
      fprintf(stderr, "- Name: %s\n", OH_InstituteData_GetName(od));
      fprintf(stderr, "- FID : %s\n", OH_InstituteData_GetFid(od));
      fprintf(stderr, "- ORG : %s\n", OH_InstituteData_GetOrg(od));
      fprintf(stderr, "- URL : %s\n", OH_InstituteData_GetUrl(od));
    }

  }
  GWEN_Dialog_free(dlg);

  AB_Gui_Unextend(gui);

  rv=AB_Banking_Fini(ab);
  if (rv<0){
    fprintf(stderr, "Error on banking fini: %d\n", rv);
    exit(2);
  }
  AB_Banking_free(ab);
  GWEN_Gui_free(gui);
#endif
  return 0;
}