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