00001 /* outboxjob.h 00002 00003 *************************************************************************** 00004 * * 00005 * This library is free software; you can redistribute it and/or * 00006 * modify it under the terms of the GNU Lesser General Public * 00007 * License as published by the Free Software Foundation; either * 00008 * version 2.1 of the License, or (at your option) any later version. * 00009 * * 00010 * This library is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00013 * Lesser General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU Lesser General Public * 00016 * License along with this library; if not, write to the Free Software * 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 00018 * MA 02111-1307 USA * 00019 * * 00020 ***************************************************************************/ 00021 00022 #ifndef OUTBOXJOB_H 00023 #define OUTBOXJOB_H 00024 00030 #ifdef __cplusplus 00031 #include <string> 00032 #include <list> 00033 #endif /* __cplusplus */ 00034 00035 #include <openhbci/dllimport.h> 00036 #include <openhbci/pointer.h> 00037 #include <openhbci/customer.h> 00038 #include <openhbci/user.h> 00039 #include <openhbci/bank.h> 00040 #include <openhbci/account.h> 00041 #include <openhbci/statusreport.h> 00042 #include <openhbci/listwrappers.h> 00043 #include <openhbci/progressmonitor.h> 00044 00045 00047 typedef enum OutboxJob_Status { 00049 HBCI_JOB_STATUS_NONE = 0, 00051 HBCI_JOB_STATUS_TODO, 00053 HBCI_JOB_STATUS_DONE 00054 } OutboxJob_Status; 00056 typedef enum OutboxJob_Result { 00058 HBCI_JOB_RESULT_NONE = 0, 00060 HBCI_JOB_RESULT_SUCCESS, 00062 HBCI_JOB_RESULT_FAILED 00063 } OutboxJob_Result; 00064 00065 #ifdef __cplusplus 00066 #include <openhbci/messagequeue.h> 00067 /* Forward declaration */ 00068 namespace HBCI { 00069 class OutboxJob; 00070 }; 00073 typedef HBCI::OutboxJob HBCI_OutboxJob; 00074 #include <openhbci/api.h> 00075 00076 /* Used to tell the the commit()-method that not the response for a 00077 * single message should be committed, but the response for the whole 00078 * job. This is because a job may consist of more than one message, 00079 * and it might be necessary to commit recieved changes before the 00080 * rest of the job is sent. */ 00081 #define HBCI_COMMIT_WHOLE_JOB -1 00082 00083 namespace HBCI { 00084 00100 class DLLIMPORT OutboxJob { 00101 friend class API; 00102 friend class Outbox; 00103 friend class customerQueue; 00104 private: 00105 OutboxJob_Status _status; 00106 int _id; 00107 list<Pointer<Customer> > _signers; 00108 MessageReference _msgReference; 00109 protected: 00110 Pointer<Customer> _cust; 00111 Pointer<Bank> _bank; 00112 OutboxJob_Result _result; 00113 00114 public: 00118 OutboxJob(Pointer<Customer> c); 00122 virtual ~OutboxJob(); 00123 00132 Pointer<Customer> customer() const { return _cust;}; 00133 00143 void addSigner(Pointer<Customer> c); 00163 OutboxJob_Status status() const { return _status;}; 00164 00178 OutboxJob_Result result() const { return _result;}; 00179 00188 int id() const { return _id;}; 00189 00194 virtual string description() const = 0; 00195 00210 virtual list<int> resultCodes() const = 0; 00211 00218 const MessageReference &messageReference() const { return _msgReference;}; 00219 00232 virtual int segmentForStatusReport() const; 00233 00238 virtual JobProgressType type() const = 0; 00239 00242 protected: 00243 00248 void addSignersToQueue(Pointer<MessageQueue> q) const; 00249 00266 virtual int messages() const { return 1;}; 00267 00270 static list<int> resultCodesFromJob(const Job& job); 00271 00284 void setId(int i) { _id=i;}; 00285 00290 void setMessageReference(const MessageReference &ref); 00291 00293 void setStatus(OutboxJob_Status s) { _status=s;}; 00294 00305 virtual bool createHBCIJobs(Pointer<MessageQueue> mbox, int n=0)=0; 00306 00318 virtual bool evaluate()=0; 00319 00335 virtual bool commit(int msgNumber=HBCI_COMMIT_WHOLE_JOB)=0; 00350 virtual bool isDialogJob() const { return false;}; 00351 00363 virtual bool stillMessagesToSend(int nextMsg) const 00364 { return nextMsg < messages(); }; 00366 }; 00367 00368 } /* namespace HBCI */ 00369 00370 extern "C" { 00371 #else /* __cplusplus */ 00372 typedef struct HBCI_OutboxJob HBCI_OutboxJob; 00373 #endif /* __cplusplus */ 00374 00379 extern void HBCI_OutboxJob_delete(HBCI_OutboxJob *j); 00380 00389 extern void HBCI_OutboxJob_addSigner(HBCI_OutboxJob *j, 00390 const HBCI_Customer *c); 00394 extern OutboxJob_Status HBCI_OutboxJob_status(const HBCI_OutboxJob *j); 00395 00397 extern OutboxJob_Result HBCI_OutboxJob_result(const HBCI_OutboxJob *j); 00398 00406 extern int HBCI_OutboxJob_id(const HBCI_OutboxJob *j); 00407 00422 extern list_int *HBCI_OutboxJob_resultCodes(const HBCI_OutboxJob *j); 00423 00428 extern const HBCI_MessageReference * 00429 HBCI_OutboxJob_messageReference(const HBCI_OutboxJob *j); 00430 00436 extern int HBCI_OutboxJob_segmentForStatusReport(const HBCI_OutboxJob *j); 00437 00442 extern JobProgressType HBCI_OutboxJob_type(const HBCI_OutboxJob *j); 00443 00446 00447 #ifdef __cplusplus 00448 } 00449 #endif /* __cplusplus */ 00450 00451 00452 #endif 00453 00454