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_ALREADYENC, 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 
42   UIMSG_FIRST,
43   UIMSG_STRING, UIMSG_BUILD, UIMSG_RRSEARCH, UIMSG_ANALYZEFILEDATA,
44   UIMSG_RRFOUND, UIMSG_RRNOTFOUND, UIMSG_RRDAMAGED, UIMSG_BLOCKSRECOVERED,
45   UIMSG_COPYINGDATA, UIMSG_AREADAMAGED, UIMSG_SECTORDAMAGED,
46   UIMSG_SECTORRECOVERED, UIMSG_SECTORNOTRECOVERED, UIMSG_FOUND,
47   UIMSG_CORRECTINGNAME, UIMSG_BADARCHIVE, UIMSG_CREATING, UIMSG_RENAMING,
48   UIMSG_RECVOLCALCCHECKSUM, UIMSG_RECVOLFOUND, UIMSG_RECVOLMISSING,
49   UIMSG_MISSINGVOL, UIMSG_RECONSTRUCTING, UIMSG_CHECKSUM, UIMSG_FAT32SIZE,
50 
51   UIWAIT_FIRST,
52   UIWAIT_DISKFULLNEXT, UIWAIT_FCREATEERROR, UIWAIT_BADPSW,
53 
54   UIEVENT_FIRST,
55   UIEVENT_SEARCHDUPFILESSTART, UIEVENT_SEARCHDUPFILESEND,
56   UIEVENT_CLEARATTRSTART, UIEVENT_CLEARATTRFILE,
57   UIEVENT_DELADDEDSTART, UIEVENT_DELADDEDFILE, UIEVENT_FILESFOUND,
58   UIEVENT_ERASEDISK, UIEVENT_FILESUMSTART, UIEVENT_FILESUMPROGRESS,
59   UIEVENT_FILESUMEND, UIEVENT_PROTECTSTART, UIEVENT_PROTECTEND,
60   UIEVENT_TESTADDEDSTART, UIEVENT_TESTADDEDEND, UIEVENT_RRTESTINGSTART,
61   UIEVENT_RRTESTINGEND, UIEVENT_NEWARCHIVE, UIEVENT_NEWREVFILE
62 };
63 
64 // Flags for uiAskReplace function.
65 enum UIASKREP_FLAGS {
66   UIASKREP_F_NORENAME=1,UIASKREP_F_EXCHSRCDEST=2,UIASKREP_F_SHOWNAMEONLY=4
67 };
68 
69 // Codes returned by uiAskReplace. Note that uiAskReplaceEx returns only
70 // UIASKREP_R_REPLACE, UIASKREP_R_SKIP and UIASKREP_R_CANCEL codes.
71 enum UIASKREP_RESULT {
72   UIASKREP_R_REPLACE,UIASKREP_R_SKIP,UIASKREP_R_REPLACEALL,UIASKREP_R_SKIPALL,
73   UIASKREP_R_RENAME,UIASKREP_R_RENAMEAUTO,UIASKREP_R_CANCEL,UIASKREP_R_UNUSED
74 };
75 
76 UIASKREP_RESULT uiAskReplace(wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags);
77 UIASKREP_RESULT uiAskReplaceEx(RAROptions *Cmd,wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags);
78 
79 void uiInit(SOUND_NOTIFY_MODE Sound);
80 
81 
82 void uiStartArchiveExtract(bool Extract,const wchar *ArcName);
83 bool uiStartFileExtract(const wchar *FileName,bool Extract,bool Test,bool Skip);
84 void uiExtractProgress(int64 CurFileSize,int64 TotalFileSize,int64 CurSize,int64 TotalSize);
85 void uiProcessProgress(const char *Command,int64 CurSize,int64 TotalSize);
86 
87 enum UIPASSWORD_TYPE {UIPASSWORD_GLOBAL,UIPASSWORD_FILE,UIPASSWORD_ARCHIVE};
88 bool uiGetPassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password);
89 bool uiIsGlobalPasswordSet();
90 
91 enum UIALARM_TYPE {UIALARM_ERROR, UIALARM_INFO, UIALARM_QUESTION};
92 void uiAlarm(UIALARM_TYPE Type);
93 
94 
95 bool uiAskNextVolume(wchar *VolName,size_t MaxSize);
96 bool uiAskRepeatRead(const wchar *FileName);
97 bool uiAskRepeatWrite(const wchar *FileName,bool DiskFull);
98 
99 #ifndef SFX_MODULE
100 const wchar *uiGetMonthName(int Month);
101 #endif
102 
103 
104 class uiMsgStore
105 {
106   private:
107     static const size_t MAX_MSG = 8;
108     const wchar *Str[MAX_MSG];
109     uint Num[MAX_MSG];
110     uint StrSize,NumSize;
111     UIMESSAGE_CODE Code;
112   public:
uiMsgStore(UIMESSAGE_CODE Code)113     uiMsgStore(UIMESSAGE_CODE Code)
114     {
115       // Init arrays in case a caller passes fewer parameters than expected.
116       for (uint I=0;I<ASIZE(Str);I++)
117         Str[I]=L"";
118       memset(Num,0,sizeof(Num));
119 
120       NumSize=StrSize=0;
121       this->Code=Code;
122     }
operator <<(const wchar * s)123     uiMsgStore& operator << (const wchar *s)
124     {
125       if (StrSize<MAX_MSG)
126         Str[StrSize++]=s;
127       return *this;
128     }
operator <<(uint n)129     uiMsgStore& operator << (uint n)
130     {
131       if (NumSize<MAX_MSG)
132         Num[NumSize++]=n;
133       return *this;
134     }
135 
136     void Msg();
137 };
138 
139 
140 // Templates recognize usual NULL as integer, not wchar*.
141 #define UINULL ((wchar *)NULL)
142 
uiMsg(UIMESSAGE_CODE Code)143 inline void uiMsg(UIMESSAGE_CODE Code)
144 {
145   uiMsgStore Store(Code);
146   Store.Msg();
147 }
148 
uiMsg(UIMESSAGE_CODE Code,T1 a1)149 template<class T1> void uiMsg(UIMESSAGE_CODE Code,T1 a1)
150 {
151   uiMsgStore Store(Code);
152   Store<<a1;
153   Store.Msg();
154 }
155 
uiMsg(UIMESSAGE_CODE Code,T1 a1,T2 a2)156 template<class T1,class T2> void uiMsg(UIMESSAGE_CODE Code,T1 a1,T2 a2)
157 {
158   uiMsgStore Store(Code);
159   Store<<a1<<a2;
160   Store.Msg();
161 }
162 
uiMsg(UIMESSAGE_CODE code,T1 a1,T2 a2,T3 a3)163 template<class T1,class T2,class T3> void uiMsg(UIMESSAGE_CODE code,T1 a1,T2 a2,T3 a3)
164 {
165   uiMsgStore Store(code);
166   Store<<a1<<a2<<a3;
167   Store.Msg();
168 }
169 
170 #endif
171