ui.hpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #ifndef _RAR_UI_
  2. #define _RAR_UI_
  3. // UIERROR_ - error message;
  4. // UIMSG_ - informational message;
  5. // UIWAIT_ - message waiting for user confirmation;
  6. // UIEVENT_ - if simple message is not enough;
  7. enum UIMESSAGE_CODE {
  8. UIERROR_SYSERRMSG, UIERROR_GENERALERRMSG, UIERROR_INCERRCOUNT,
  9. UIERROR_CHECKSUM, UIERROR_CHECKSUMENC, UIERROR_CHECKSUMPACKED,
  10. UIERROR_BADPSW, UIERROR_MEMORY, UIERROR_FILEOPEN, UIERROR_FILECREATE,
  11. UIERROR_FILECLOSE, UIERROR_FILESEEK, UIERROR_FILEREAD, UIERROR_FILEWRITE,
  12. UIERROR_FILEDELETE, UIERROR_RECYCLEFAILED, UIERROR_FILERENAME,
  13. UIERROR_FILEATTR, UIERROR_FILECOPY, UIERROR_FILECOPYHINT,
  14. UIERROR_DIRCREATE, UIERROR_SLINKCREATE, UIERROR_HLINKCREATE,
  15. UIERROR_NOLINKTARGET, UIERROR_NEEDADMIN, UIERROR_ARCBROKEN,
  16. UIERROR_HEADERBROKEN, UIERROR_MHEADERBROKEN, UIERROR_FHEADERBROKEN,
  17. UIERROR_SUBHEADERBROKEN, UIERROR_SUBHEADERUNKNOWN,
  18. UIERROR_SUBHEADERDATABROKEN, UIERROR_RRDAMAGED, UIERROR_UNKNOWNMETHOD,
  19. UIERROR_UNKNOWNENCMETHOD, UIERROR_RENAMING, UIERROR_NEWERRAR,
  20. UIERROR_NOTSFX, UIERROR_OLDTOSFX,
  21. UIERROR_WRONGSFXVER, UIERROR_HEADENCMISMATCH, UIERROR_DICTOUTMEM,
  22. UIERROR_USESMALLERDICT, UIERROR_MODIFYUNKNOWN, UIERROR_MODIFYOLD,
  23. UIERROR_MODIFYLOCKED, UIERROR_MODIFYVOLUME, UIERROR_NOTVOLUME,
  24. UIERROR_NOTFIRSTVOLUME, UIERROR_RECVOLLIMIT, UIERROR_RECVOLDIFFSETS,
  25. UIERROR_RECVOLALLEXIST, UIERROR_RECVOLFOUND, UIERROR_RECONSTRUCTING,
  26. UIERROR_RECVOLCANNOTFIX, UIERROR_OPFAILED, UIERROR_UNEXPEOF,
  27. UIERROR_BADARCHIVE, UIERROR_CMTBROKEN, UIERROR_INVALIDNAME,
  28. UIERROR_NEWRARFORMAT, UIERROR_NOTSUPPORTED, UIERROR_ENCRNOTSUPPORTED,
  29. UIERROR_RARZIPONLY, UIERROR_REPAIROLDFORMAT, UIERROR_NOFILESREPAIRED,
  30. UIERROR_NOFILESTOADD, UIERROR_NOFILESTODELETE, UIERROR_NOFILESTOEXTRACT,
  31. UIERROR_MISSINGVOL, UIERROR_NEEDPREVVOL, UIERROR_UNKNOWNEXTRA,
  32. UIERROR_CORRUPTEXTRA, UIERROR_NTFSREQUIRED, UIERROR_ZIPVOLSFX,
  33. UIERROR_FILERO, UIERROR_TOOLARGESFX, UIERROR_NOZIPSFX, UIERROR_EMAIL,
  34. UIERROR_ACLGET, UIERROR_ACLBROKEN, UIERROR_ACLUNKNOWN, UIERROR_ACLSET,
  35. UIERROR_STREAMBROKEN, UIERROR_STREAMUNKNOWN, UIERROR_INCOMPATSWITCH,
  36. UIERROR_PATHTOOLONG, UIERROR_DIRSCAN, UIERROR_UOWNERGET,
  37. UIERROR_UOWNERBROKEN, UIERROR_UOWNERGETOWNERID, UIERROR_UOWNERGETGROUPID,
  38. UIERROR_UOWNERSET, UIERROR_ULINKREAD, UIERROR_ULINKEXIST,
  39. UIERROR_OPENPRESERVEATIME, UIERROR_READERRTRUNCATED, UIERROR_READERRCOUNT,
  40. UIERROR_DIRNAMEEXISTS,UIERROR_TRUNCPSW,UIERROR_ADJUSTVALUE,
  41. UIMSG_FIRST,
  42. UIMSG_STRING, UIMSG_BUILD, UIMSG_RRSEARCH, UIMSG_ANALYZEFILEDATA,
  43. UIMSG_RRFOUND, UIMSG_RRNOTFOUND, UIMSG_RRDAMAGED, UIMSG_BLOCKSRECOVERED,
  44. UIMSG_COPYINGDATA, UIMSG_AREADAMAGED, UIMSG_SECTORDAMAGED,
  45. UIMSG_SECTORRECOVERED, UIMSG_SECTORNOTRECOVERED, UIMSG_FOUND,
  46. UIMSG_CORRECTINGNAME, UIMSG_BADARCHIVE, UIMSG_CREATING, UIMSG_RENAMING,
  47. UIMSG_RECVOLCALCCHECKSUM, UIMSG_RECVOLFOUND, UIMSG_RECVOLMISSING,
  48. UIMSG_MISSINGVOL, UIMSG_RECONSTRUCTING, UIMSG_CHECKSUM, UIMSG_FAT32SIZE,
  49. UIMSG_SKIPENCARC,
  50. UIWAIT_FIRST,
  51. UIWAIT_DISKFULLNEXT, UIWAIT_FCREATEERROR, UIWAIT_BADPSW,
  52. UIEVENT_FIRST,
  53. UIEVENT_SEARCHDUPFILESSTART, UIEVENT_SEARCHDUPFILESEND,
  54. UIEVENT_CLEARATTRSTART, UIEVENT_CLEARATTRFILE,
  55. UIEVENT_DELADDEDSTART, UIEVENT_DELADDEDFILE, UIEVENT_FILESFOUND,
  56. UIEVENT_ERASEDISK, UIEVENT_FILESUMSTART, UIEVENT_FILESUMPROGRESS,
  57. UIEVENT_FILESUMEND, UIEVENT_PROTECTSTART, UIEVENT_PROTECTEND,
  58. UIEVENT_TESTADDEDSTART, UIEVENT_TESTADDEDEND, UIEVENT_RRTESTINGSTART,
  59. UIEVENT_RRTESTINGEND, UIEVENT_NEWARCHIVE, UIEVENT_NEWREVFILE
  60. };
  61. // Flags for uiAskReplace function.
  62. enum UIASKREP_FLAGS {
  63. UIASKREP_F_NORENAME=1,UIASKREP_F_EXCHSRCDEST=2,UIASKREP_F_SHOWNAMEONLY=4
  64. };
  65. // Codes returned by uiAskReplace. Note that uiAskReplaceEx returns only
  66. // UIASKREP_R_REPLACE, UIASKREP_R_SKIP and UIASKREP_R_CANCEL codes.
  67. enum UIASKREP_RESULT {
  68. UIASKREP_R_REPLACE,UIASKREP_R_SKIP,UIASKREP_R_REPLACEALL,UIASKREP_R_SKIPALL,
  69. UIASKREP_R_RENAME,UIASKREP_R_RENAMEAUTO,UIASKREP_R_CANCEL,UIASKREP_R_UNUSED
  70. };
  71. UIASKREP_RESULT uiAskReplace(wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags);
  72. UIASKREP_RESULT uiAskReplaceEx(RAROptions *Cmd,wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags);
  73. void uiInit(SOUND_NOTIFY_MODE Sound);
  74. void uiStartArchiveExtract(bool Extract,const wchar *ArcName);
  75. bool uiStartFileExtract(const wchar *FileName,bool Extract,bool Test,bool Skip);
  76. void uiExtractProgress(int64 CurFileSize,int64 TotalFileSize,int64 CurSize,int64 TotalSize);
  77. void uiProcessProgress(const char *Command,int64 CurSize,int64 TotalSize);
  78. enum UIPASSWORD_TYPE {UIPASSWORD_GLOBAL,UIPASSWORD_FILE,UIPASSWORD_ARCHIVE};
  79. bool uiGetPassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password);
  80. bool uiIsGlobalPasswordSet();
  81. enum UIALARM_TYPE {UIALARM_ERROR, UIALARM_INFO, UIALARM_QUESTION};
  82. void uiAlarm(UIALARM_TYPE Type);
  83. void uiEolAfterMsg();
  84. bool uiAskNextVolume(wchar *VolName,size_t MaxSize);
  85. #if !defined(SILENT) && !defined(SFX_MODULE)
  86. void uiAskRepeatRead(const wchar *FileName,bool &Ignore,bool &All,bool &Retry,bool &Quit);
  87. #endif
  88. bool uiAskRepeatWrite(const wchar *FileName,bool DiskFull);
  89. #ifndef SFX_MODULE
  90. const wchar *uiGetMonthName(int Month);
  91. #endif
  92. class uiMsgStore
  93. {
  94. private:
  95. static const size_t MAX_MSG = 8;
  96. const wchar *Str[MAX_MSG];
  97. uint Num[MAX_MSG];
  98. uint StrSize,NumSize;
  99. UIMESSAGE_CODE Code;
  100. public:
  101. uiMsgStore(UIMESSAGE_CODE Code)
  102. {
  103. // Init arrays in case a caller passes fewer parameters than expected.
  104. for (uint I=0;I<ASIZE(Str);I++)
  105. Str[I]=L"";
  106. memset(Num,0,sizeof(Num));
  107. NumSize=StrSize=0;
  108. this->Code=Code;
  109. }
  110. uiMsgStore& operator << (const wchar *s)
  111. {
  112. if (StrSize<MAX_MSG)
  113. Str[StrSize++]=s;
  114. return *this;
  115. }
  116. uiMsgStore& operator << (uint n)
  117. {
  118. if (NumSize<MAX_MSG)
  119. Num[NumSize++]=n;
  120. return *this;
  121. }
  122. void Msg();
  123. };
  124. // Templates recognize usual NULL as integer, not wchar*.
  125. #define UINULL ((wchar *)NULL)
  126. inline void uiMsg(UIMESSAGE_CODE Code)
  127. {
  128. uiMsgStore Store(Code);
  129. Store.Msg();
  130. }
  131. template<class T1> void uiMsg(UIMESSAGE_CODE Code,T1 a1)
  132. {
  133. uiMsgStore Store(Code);
  134. Store<<a1;
  135. Store.Msg();
  136. }
  137. template<class T1,class T2> void uiMsg(UIMESSAGE_CODE Code,T1 a1,T2 a2)
  138. {
  139. uiMsgStore Store(Code);
  140. Store<<a1<<a2;
  141. Store.Msg();
  142. }
  143. template<class T1,class T2,class T3> void uiMsg(UIMESSAGE_CODE code,T1 a1,T2 a2,T3 a3)
  144. {
  145. uiMsgStore Store(code);
  146. Store<<a1<<a2<<a3;
  147. Store.Msg();
  148. }
  149. #endif