Coverage Report

Created: 2023-06-07 06:02

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