| | 51 | public class UnknownException : TnyException { |
|---|
| | 52 | public UnknownException (IntPtr Handle) : base (Handle) { } |
|---|
| | 53 | } |
|---|
| | 54 | |
|---|
| | 55 | public class MemoryException : TnyException { |
|---|
| | 56 | public MemoryException (IntPtr Handle) : base (Handle) { } |
|---|
| | 57 | } |
|---|
| | 58 | |
|---|
| | 59 | public class CancelException : TnyException { |
|---|
| | 60 | public CancelException (IntPtr Handle) : base (Handle) { } |
|---|
| | 61 | } |
|---|
| | 62 | |
|---|
| | 63 | public class IOException : TnyException { |
|---|
| | 64 | public IOException (IntPtr Handle) : base (Handle) { } |
|---|
| | 65 | } |
|---|
| | 66 | |
|---|
| | 67 | public class AuthenticateException : TnyException { |
|---|
| | 68 | public AuthenticateException (IntPtr Handle) : base (Handle) { } |
|---|
| | 69 | } |
|---|
| | 70 | |
|---|
| | 71 | public class ConnectException : TnyException { |
|---|
| | 72 | public ConnectException (IntPtr Handle) : base (Handle) { } |
|---|
| | 73 | } |
|---|
| | 74 | |
|---|
| | 75 | public class ServiceUnavailableException : TnyException { |
|---|
| | 76 | public ServiceUnavailableException (IntPtr Handle) : base (Handle) { } |
|---|
| | 77 | } |
|---|
| | 78 | |
|---|
| | 79 | public class LostConnectionException : TnyException { |
|---|
| | 80 | public LostConnectionException (IntPtr Handle) : base (Handle) { } |
|---|
| | 81 | } |
|---|
| | 82 | |
|---|
| | 83 | public class CertificateException : TnyException { |
|---|
| | 84 | public CertificateException (IntPtr Handle) : base (Handle) { } |
|---|
| | 85 | } |
|---|
| | 86 | |
|---|
| | 87 | public class FolderCreateException : TnyException { |
|---|
| | 88 | public FolderCreateException (IntPtr Handle) : base (Handle) { } |
|---|
| | 89 | } |
|---|
| | 90 | |
|---|
| | 91 | public class FolderRemoveException : TnyException { |
|---|
| | 92 | public FolderRemoveException (IntPtr Handle) : base (Handle) { } |
|---|
| | 93 | } |
|---|
| | 94 | |
|---|
| | 95 | public class FolderRenameException : TnyException { |
|---|
| | 96 | public FolderRenameException (IntPtr Handle) : base (Handle) { } |
|---|
| | 97 | } |
|---|
| | 98 | |
|---|
| | 99 | public class FolderIsUnknownException : TnyException { |
|---|
| | 100 | public FolderIsUnknownException (IntPtr Handle) : base (Handle) { } |
|---|
| | 101 | } |
|---|
| | 102 | |
|---|
| | 103 | public class ProtocolException : TnyException { |
|---|
| | 104 | public ProtocolException (IntPtr Handle) : base (Handle) { } |
|---|
| | 105 | } |
|---|
| | 106 | |
|---|
| | 107 | public class ActionUnsupportedException : TnyException { |
|---|
| | 108 | public ActionUnsupportedException (IntPtr Handle) : base (Handle) { } |
|---|
| | 109 | } |
|---|
| | 110 | |
|---|
| | 111 | public class NoSuchMessageException : TnyException { |
|---|
| | 112 | public NoSuchMessageException (IntPtr Handle) : base (Handle) { } |
|---|
| | 113 | } |
|---|
| | 114 | |
|---|
| | 115 | public class MessageNotAvailableException : TnyException { |
|---|
| | 116 | public MessageNotAvailableException (IntPtr Handle) : base (Handle) { } |
|---|
| | 117 | } |
|---|
| | 118 | |
|---|
| | 119 | public class StateException : TnyException { |
|---|
| | 120 | public StateException (IntPtr Handle) : base (Handle) { } |
|---|
| | 121 | } |
|---|
| | 122 | |
|---|
| | 123 | public class AddMsgException : TnyException { |
|---|
| | 124 | public AddMsgException (IntPtr Handle) : base (Handle) { } |
|---|
| | 125 | } |
|---|
| | 126 | |
|---|
| | 127 | public class RemoveMsgException : TnyException { |
|---|
| | 128 | public RemoveMsgException (IntPtr Handle) : base (Handle) { } |
|---|
| | 129 | } |
|---|
| | 130 | |
|---|
| | 131 | public class GetMsgException : TnyException { |
|---|
| | 132 | public GetMsgException (IntPtr Handle) : base (Handle) { } |
|---|
| | 133 | } |
|---|
| | 134 | |
|---|
| | 135 | public class SyncException : TnyException { |
|---|
| | 136 | public SyncException (IntPtr Handle) : base (Handle) { } |
|---|
| | 137 | } |
|---|
| | 138 | |
|---|
| | 139 | public class RefreshException : TnyException { |
|---|
| | 140 | public RefreshException (IntPtr Handle) : base (Handle) { } |
|---|
| | 141 | } |
|---|
| | 142 | |
|---|
| | 143 | public class CopyException : TnyException { |
|---|
| | 144 | public CopyException (IntPtr Handle) : base (Handle) { } |
|---|
| | 145 | } |
|---|
| | 146 | |
|---|
| | 147 | public class TransferException : TnyException { |
|---|
| | 148 | public TransferException (IntPtr Handle) : base (Handle) { } |
|---|
| | 149 | } |
|---|
| | 150 | |
|---|
| | 151 | public class GetFoldersException : TnyException { |
|---|
| | 152 | public GetFoldersException (IntPtr Handle) : base (Handle) { } |
|---|
| | 153 | } |
|---|
| | 154 | |
|---|
| | 155 | public class SendException : TnyException { |
|---|
| | 156 | public SendException (IntPtr Handle) : base (Handle) { } |
|---|
| | 157 | } |
|---|
| | 158 | |
|---|
| | 159 | public class MimeMalformedException : TnyException { |
|---|
| | 160 | public MimeMalformedException (IntPtr Handle) : base (Handle) { } |
|---|
| | 161 | } |
|---|
| | 162 | |
|---|
| | 163 | public class TnyExceptionFactory { |
|---|
| | 164 | |
|---|
| | 165 | [DllImport("libtinymail-1.0.dll")] |
|---|
| | 166 | static extern int tny_error_get_code (IntPtr Handle); |
|---|
| | 167 | |
|---|
| | 168 | public static TnyException Create (IntPtr Handle) { |
|---|
| | 169 | |
|---|
| | 170 | TnyException ex = null; |
|---|
| | 171 | ErrorEnum code = Handle != IntPtr.Zero ? (ErrorEnum) tny_error_get_code (Handle) : ErrorEnum.NoError; |
|---|
| | 172 | |
|---|
| | 173 | switch (code) { |
|---|
| | 174 | |
|---|
| | 175 | case ErrorEnum.ServiceErrorUnknown: |
|---|
| | 176 | ex = new UnknownException (Handle); |
|---|
| | 177 | break; |
|---|
| | 178 | |
|---|
| | 179 | case ErrorEnum.SystemErrorUnknown: |
|---|
| | 180 | ex = new UnknownException (Handle); |
|---|
| | 181 | break; |
|---|
| | 182 | |
|---|
| | 183 | case ErrorEnum.SystemErrorMemory: |
|---|
| | 184 | ex = new MemoryException (Handle); |
|---|
| | 185 | break; |
|---|
| | 186 | |
|---|
| | 187 | case ErrorEnum.SystemErrorCancel: |
|---|
| | 188 | ex = new CancelException (Handle); |
|---|
| | 189 | break; |
|---|
| | 190 | |
|---|
| | 191 | case ErrorEnum.IoErrorWrite: |
|---|
| | 192 | ex = new IOException (Handle); |
|---|
| | 193 | break; |
|---|
| | 194 | |
|---|
| | 195 | case ErrorEnum.IoErrorRead: |
|---|
| | 196 | ex = new IOException (Handle); |
|---|
| | 197 | break; |
|---|
| | 198 | |
|---|
| | 199 | case ErrorEnum.ServiceErrorAuthenticate: |
|---|
| | 200 | ex = new AuthenticateException (Handle); |
|---|
| | 201 | break; |
|---|
| | 202 | case ErrorEnum.ServiceErrorConnect: |
|---|
| | 203 | ex = new ConnectException (Handle); |
|---|
| | 204 | break; |
|---|
| | 205 | |
|---|
| | 206 | case ErrorEnum.ServiceErrorUnavailable: |
|---|
| | 207 | ex = new ServiceUnavailableException (Handle); |
|---|
| | 208 | break; |
|---|
| | 209 | case ErrorEnum.ServiceErrorLostConnection: |
|---|
| | 210 | ex = new LostConnectionException (Handle); |
|---|
| | 211 | break; |
|---|
| | 212 | |
|---|
| | 213 | case ErrorEnum.ServiceErrorCertificate: |
|---|
| | 214 | ex = new CertificateException (Handle); |
|---|
| | 215 | break; |
|---|
| | 216 | |
|---|
| | 217 | case ErrorEnum.ServiceErrorFolderCreate: |
|---|
| | 218 | ex = new FolderCreateException (Handle); |
|---|
| | 219 | break; |
|---|
| | 220 | |
|---|
| | 221 | case ErrorEnum.ServiceErrorFolderRemove: |
|---|
| | 222 | ex = new FolderRemoveException (Handle); |
|---|
| | 223 | break; |
|---|
| | 224 | case ErrorEnum.ServiceErrorFolderRename: |
|---|
| | 225 | ex = new FolderRenameException (Handle); |
|---|
| | 226 | break; |
|---|
| | 227 | |
|---|
| | 228 | case ErrorEnum.ServiceErrorFolderIsUnknown: |
|---|
| | 229 | ex = new FolderIsUnknownException (Handle); |
|---|
| | 230 | break; |
|---|
| | 231 | |
|---|
| | 232 | case ErrorEnum.ServiceErrorProtocol: |
|---|
| | 233 | ex = new ProtocolException (Handle); |
|---|
| | 234 | break; |
|---|
| | 235 | |
|---|
| | 236 | case ErrorEnum.ServiceErrorUnsupported: |
|---|
| | 237 | ex = new ActionUnsupportedException (Handle); |
|---|
| | 238 | break; |
|---|
| | 239 | |
|---|
| | 240 | case ErrorEnum.ServiceErrorNoSuchMessage: |
|---|
| | 241 | ex = new NoSuchMessageException (Handle); |
|---|
| | 242 | break; |
|---|
| | 243 | |
|---|
| | 244 | case ErrorEnum.ServiceErrorMessageNotAvailable: |
|---|
| | 245 | ex = new MessageNotAvailableException (Handle); |
|---|
| | 246 | break; |
|---|
| | 247 | |
|---|
| | 248 | case ErrorEnum.ServiceErrorState: |
|---|
| | 249 | ex = new StateException (Handle); |
|---|
| | 250 | break; |
|---|
| | 251 | |
|---|
| | 252 | case ErrorEnum.MimeErrorState: |
|---|
| | 253 | ex = new StateException (Handle); |
|---|
| | 254 | break; |
|---|
| | 255 | |
|---|
| | 256 | case ErrorEnum.ServiceErrorAddMsg: |
|---|
| | 257 | ex = new AddMsgException (Handle); |
|---|
| | 258 | break; |
|---|
| | 259 | |
|---|
| | 260 | case ErrorEnum.ServiceErrorRemoveMsg: |
|---|
| | 261 | ex = new RemoveMsgException (Handle); |
|---|
| | 262 | break; |
|---|
| | 263 | |
|---|
| | 264 | case ErrorEnum.ServiceErrorGetMsg: |
|---|
| | 265 | ex = new GetMsgException (Handle); |
|---|
| | 266 | break; |
|---|
| | 267 | |
|---|
| | 268 | case ErrorEnum.ServiceErrorSync: |
|---|
| | 269 | ex = new SyncException (Handle); |
|---|
| | 270 | break; |
|---|
| | 271 | |
|---|
| | 272 | case ErrorEnum.ServiceErrorRefresh: |
|---|
| | 273 | ex = new RefreshException (Handle); |
|---|
| | 274 | break; |
|---|
| | 275 | |
|---|
| | 276 | case ErrorEnum.ServiceErrorCopy: |
|---|
| | 277 | ex = new CopyException (Handle); |
|---|
| | 278 | break; |
|---|
| | 279 | |
|---|
| | 280 | case ErrorEnum.ServiceErrorTransfer: |
|---|
| | 281 | ex = new TransferException (Handle); |
|---|
| | 282 | break; |
|---|
| | 283 | |
|---|
| | 284 | case ErrorEnum.ServiceErrorGetFolders: |
|---|
| | 285 | ex = new GetFoldersException (Handle); |
|---|
| | 286 | break; |
|---|
| | 287 | |
|---|
| | 288 | case ErrorEnum.ServiceErrorSend: |
|---|
| | 289 | ex = new SendException (Handle); |
|---|
| | 290 | break; |
|---|
| | 291 | |
|---|
| | 292 | case ErrorEnum.MimeErrorMalformed: |
|---|
| | 293 | ex = new MimeMalformedException (Handle); |
|---|
| | 294 | break; |
|---|
| | 295 | |
|---|
| | 296 | case ErrorEnum.NoError: |
|---|
| | 297 | ex = new TnyException (Handle); |
|---|
| | 298 | break; |
|---|
| | 299 | |
|---|
| | 300 | default: |
|---|
| | 301 | ex = new TnyException (Handle); |
|---|
| | 302 | break; |
|---|
| | 303 | |
|---|
| | 304 | } |
|---|
| | 305 | |
|---|
| | 306 | return ex; |
|---|
| | 307 | } |
|---|
| | 308 | } |
|---|