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