00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "result.h"
00023
00024 #include <opensync/opensync.h>
00025
00026 using namespace QSync;
00027
00028 Result::Result()
00029 : mType( NoError )
00030 {
00031 }
00032
00033 Result::Result( Type type )
00034 : mType( type )
00035 {
00036 }
00037
00038 Result::Result( OSyncError **error, bool deleteError )
00039 {
00040 OSyncErrorType otype = osync_error_get_type( error );
00041 Type type;
00042
00043 switch ( otype ) {
00044 case OSYNC_NO_ERROR:
00045 type = NoError;
00046 break;
00047 default:
00048 case OSYNC_ERROR_GENERIC:
00049 type = GenericError;
00050 break;
00051 case OSYNC_ERROR_IO_ERROR:
00052 type = IOError;
00053 break;
00054 case OSYNC_ERROR_NOT_SUPPORTED:
00055 type = NotSupported;
00056 break;
00057 case OSYNC_ERROR_TIMEOUT:
00058 type = Timeout;
00059 break;
00060 case OSYNC_ERROR_DISCONNECTED:
00061 type = Disconnected;
00062 break;
00063 case OSYNC_ERROR_FILE_NOT_FOUND:
00064 type = FileNotFound;
00065 break;
00066 case OSYNC_ERROR_EXISTS:
00067 type = Exists;
00068 break;
00069 case OSYNC_ERROR_CONVERT:
00070 type = Convert;
00071 break;
00072 case OSYNC_ERROR_MISCONFIGURATION:
00073 type = Misconfiguration;
00074 break;
00075 case OSYNC_ERROR_INITIALIZATION:
00076 type = Initialization;
00077 break;
00078 case OSYNC_ERROR_PARAMETER:
00079 type = Parameter;
00080 break;
00081 case OSYNC_ERROR_EXPECTED:
00082 type = Expected;
00083 break;
00084 case OSYNC_ERROR_NO_CONNECTION:
00085 type = NoConnection;
00086 break;
00087 case OSYNC_ERROR_TEMPORARY:
00088 type = Temporary;
00089 break;
00090 case OSYNC_ERROR_LOCKED:
00091 type = Locked;
00092 break;
00093 case OSYNC_ERROR_PLUGIN_NOT_FOUND:
00094 type = PluginNotFound;
00095 break;
00096 }
00097
00098 mType = type;
00099 mName = TQString::fromUtf8( osync_error_get_name( error ) );
00100 mMessage = TQString::fromUtf8( osync_error_print( error ) );
00101
00102 if ( deleteError )
00103 osync_error_free( error );
00104 }
00105
00106 Result::~Result()
00107 {
00108 }
00109
00110 void Result::setName( const TQString &name )
00111 {
00112 mName = name;
00113 }
00114
00115 TQString Result::name() const
00116 {
00117 return mName;
00118 }
00119
00120 void Result::setMessage( const TQString &message )
00121 {
00122 mMessage = message;
00123 }
00124
00125 TQString Result::message() const
00126 {
00127 return mMessage;
00128 }
00129
00130 void Result::setType( Type type )
00131 {
00132 mType = type;
00133 }
00134
00135 Result::Type Result::type() const
00136 {
00137 return mType;
00138 }
00139
00140 bool Result::isError() const
00141 {
00142 return mType != NoError;
00143 }
00144
00145 Result::operator bool () const
00146 {
00147 return ( mType != NoError );
00148 }
00149