svn-gvsig-desktop / tags / v1_1_1_Build_1016 / libraries / libjni-mrsid / include / mrsid_readers / MrSIDPasswordDelegate.h @ 44700
History | View | Annotate | Download (4.37 KB)
1 |
/* $Id: MrSIDPasswordDelegate.h 3539 2006-01-09 12:23:20Z nacho $ */
|
---|---|
2 |
/* //////////////////////////////////////////////////////////////////////////
|
3 |
// //
|
4 |
// This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue, //
|
5 |
// Suite 200, Seattle, WA 98104. Unauthorized use or distribution //
|
6 |
// prohibited. Access to and use of this code is permitted only under //
|
7 |
// license from LizardTech, Inc. Portions of the code are protected by //
|
8 |
// US and foreign patents and other filings. All Rights Reserved. //
|
9 |
// //
|
10 |
////////////////////////////////////////////////////////////////////////// */
|
11 |
/* PUBLIC */
|
12 |
|
13 |
#ifndef MRSIDPASSWORDDELEGATE_H
|
14 |
#define MRSIDPASSWORDDELEGATE_H
|
15 |
|
16 |
// lt_lib_base
|
17 |
#include "lt_base.h" |
18 |
|
19 |
|
20 |
LT_BEGIN_NAMESPACE(LizardTech) |
21 |
|
22 |
#if defined(LT_COMPILER_MS)
|
23 |
#pragma warning(push,4) |
24 |
#endif
|
25 |
|
26 |
|
27 |
class EncryptImp; |
28 |
class MrSIDImageReaderBase; |
29 |
class MG2ImageWriter; |
30 |
class MG3ImageWriter; |
31 |
|
32 |
|
33 |
/**
|
34 |
* delegate for locked MrSID images
|
35 |
*
|
36 |
* This abstract class is used with MrSIDImageReaderBase::setPasswordDelegate()
|
37 |
* to supply a user-callback mechanism for supplying text passwords to
|
38 |
* the internal MrSID decoder logic.
|
39 |
*
|
40 |
* Users should derive their own class from this, supplying their own
|
41 |
* reportIncorrectPassword() and getPassword() methods.
|
42 |
*/
|
43 |
class MrSIDPasswordDelegate |
44 |
{ |
45 |
public:
|
46 |
/**
|
47 |
* constructor
|
48 |
*/
|
49 |
MrSIDPasswordDelegate(); |
50 |
|
51 |
/**
|
52 |
* destructor
|
53 |
*/
|
54 |
virtual ~MrSIDPasswordDelegate(); |
55 |
|
56 |
/**
|
57 |
* user function for user notification
|
58 |
*
|
59 |
* This function is called by the decoder if the password
|
60 |
* entered was incorrect. Derived classes must implement
|
61 |
* this function, e.g. to pop up a message box, abort the
|
62 |
* operation, etc.
|
63 |
*
|
64 |
* @return success or failure in reporting to user
|
65 |
*/
|
66 |
virtual LT_STATUS reportIncorrectPassword() = 0;
|
67 |
|
68 |
/**
|
69 |
* user function for getting the password
|
70 |
*
|
71 |
* This function is called by the decoder to request a password
|
72 |
* from the user. Derived classes must implement
|
73 |
* this function, e.g. to pop up a text-entry dialog box.
|
74 |
*
|
75 |
* The implementation of this function must copy the password
|
76 |
* into the buffer pointed by getPasswordBuffer().
|
77 |
*
|
78 |
* @return success or failure in getting password from user
|
79 |
*/
|
80 |
virtual LT_STATUS getPassword() = 0;
|
81 |
|
82 |
protected:
|
83 |
/**
|
84 |
* get password buffer
|
85 |
*
|
86 |
* This function returns a pointer to the allocated area for the
|
87 |
* password obtained from the user.
|
88 |
*
|
89 |
* @return pointer to the password buffer
|
90 |
*/
|
91 |
char* getPasswordBuffer();
|
92 |
|
93 |
/**
|
94 |
* get password buffer length
|
95 |
*
|
96 |
* This function returns the length of the buffer returned from
|
97 |
* getPasswordBuffer().
|
98 |
*
|
99 |
* @return length of the password buffer
|
100 |
*/
|
101 |
lt_uint32 getPasswordBufferLength(); |
102 |
|
103 |
private:
|
104 |
friend class EncryptImp; |
105 |
EncryptImp* m_encryptImp; |
106 |
char* m_passwordBuffer;
|
107 |
|
108 |
static const lt_uint32 s_passwordBufferLength; |
109 |
|
110 |
friend class MrSIDImageReaderBase; |
111 |
friend class MG2ImageWriter; |
112 |
friend class MG3ImageWriter; |
113 |
void registerProvider();
|
114 |
|
115 |
// nope
|
116 |
MrSIDPasswordDelegate(const MrSIDPasswordDelegate&);
|
117 |
MrSIDPasswordDelegate& operator=(const MrSIDPasswordDelegate&);
|
118 |
}; |
119 |
|
120 |
|
121 |
/**
|
122 |
* simple concrete delegate for locked MrSID images
|
123 |
*
|
124 |
* This class is a concrete password delegate class which just
|
125 |
* takes a fixed string in its ctor.
|
126 |
*/
|
127 |
class MrSIDSimplePasswordDelegate : public MrSIDPasswordDelegate |
128 |
{ |
129 |
public:
|
130 |
/**
|
131 |
* constructor
|
132 |
*
|
133 |
* Create a password delegate, using the given string.
|
134 |
*
|
135 |
* @param password the password to use to unlock the image
|
136 |
*/
|
137 |
MrSIDSimplePasswordDelegate(const char* password); |
138 |
|
139 |
/**
|
140 |
* failure user notification
|
141 |
*
|
142 |
* This function just returns LT_STS_Failure.
|
143 |
*
|
144 |
* @return always LT_STS_Failure
|
145 |
*/
|
146 |
LT_STATUS reportIncorrectPassword(); |
147 |
|
148 |
/**
|
149 |
* get the password
|
150 |
*
|
151 |
* This function does nothing, as the password is fixed (determined
|
152 |
* by parameter to constructor).
|
153 |
*
|
154 |
* @return always LT_STS_Success
|
155 |
*/
|
156 |
LT_STATUS getPassword(); |
157 |
|
158 |
private:
|
159 |
// nope
|
160 |
MrSIDSimplePasswordDelegate(const MrSIDSimplePasswordDelegate&);
|
161 |
MrSIDSimplePasswordDelegate& operator=(const MrSIDSimplePasswordDelegate&);
|
162 |
}; |
163 |
|
164 |
|
165 |
LT_END_NAMESPACE(LizardTech) |
166 |
|
167 |
#if defined(LT_COMPILER_MS)
|
168 |
#pragma warning(pop)
|
169 |
#endif
|
170 |
|
171 |
#endif // MRSIDPASSWORDDELEGATE_H |