/* get result code from 2ch tag or title. */ /* private */
int KitaWriteView::resultCode( const QString& response ) const
{
- int retcode = K2ch_Unknown;;
-
QRegExp regexp( "<!-- 2ch_X:(.*) -->" );
int pos = regexp.search( response );
- QString k2ch_X;
- if ( pos != -1 ) { /* get code from 2ch tag */
-
- k2ch_X = regexp.cap( 1 );
-
- if ( k2ch_X == "true" ) retcode = K2ch_True;
- else if ( k2ch_X == "false" ) retcode = K2ch_False;
- else if ( k2ch_X == "error" ) retcode = K2ch_Error;
- else if ( k2ch_X == "check" ) retcode = K2ch_Check;
- else if ( k2ch_X == "cookie" ) retcode = K2ch_Cookie;
+ if ( pos != -1 ) {
+ /* get code from 2ch tag */
+ QString k2ch_X = regexp.cap( 1 );
- } else { /* get code from title */
+ if ( k2ch_X == "true" ) return K2ch_True;
+ if ( k2ch_X == "false" ) return K2ch_False;
+ if ( k2ch_X == "error" ) return K2ch_Error;
+ if ( k2ch_X == "check" ) return K2ch_Check;
+ if ( k2ch_X == "cookie" ) return K2ch_Cookie;
+ return K2ch_Unknown;
+ } else {
+ /* get code from title */
QString title = resultTitle( response );
+ if ( title == QString::null ) return K2ch_Unknown;
+
+ /* see also libkita/kita-utf8.h */
+ QString errstr = QTextCodec::codecForName( "utf8" ) ->toUnicode( KITAUTF8_WRITEERROR );
+ QString truestr = QTextCodec::codecForName( "utf8" ) ->toUnicode( KITAUTF8_WRITETRUE );
+ QString ckstr = QTextCodec::codecForName( "utf8" ) ->toUnicode( KITAUTF8_WRITECOOKIE );
+
+ if ( title.contains( errstr ) ) return K2ch_Error;
+ if ( title.contains( truestr ) ) return K2ch_True;
+ if ( title.contains( ckstr ) ) return K2ch_Cookie;
+
+ /* re-post new thread message. adhock... */
+ if ( m_mode == WRITEMODE_NEWTHREAD
+ && response.contains( ckstr )
+ && response.contains( "subbbs.cgi" ) ) {
+ return K2ch_NewThread;
+ }
- if ( title != QString::null ) {
-
- /* see also libkita/kita-utf8.h */
- QString errstr = QTextCodec::codecForName( "utf8" ) ->toUnicode( KITAUTF8_WRITEERROR );
- QString truestr = QTextCodec::codecForName( "utf8" ) ->toUnicode( KITAUTF8_WRITETRUE );
- QString ckstr = QTextCodec::codecForName( "utf8" ) ->toUnicode( KITAUTF8_WRITECOOKIE );
-
- if ( title.contains( errstr ) ) retcode = K2ch_Error;
- else if ( title.contains( truestr ) ) retcode = K2ch_True;
- else if ( title.contains( ckstr ) ) retcode = K2ch_Cookie;
-
- /* re-post new thread message. adhock... */
- else if ( m_mode == WRITEMODE_NEWTHREAD
- && response.contains( ckstr )
- && response.contains( "subbbs.cgi" ) ) retcode = K2ch_NewThread;
-
- /* for Flash CGI */
- else if ( m_bbstype == Kita::Board_FlashCGI ) {
-
- if ( title.contains( "ERROR!!" ) ) retcode = K2ch_Error;
- else retcode = K2ch_True;
+ /* for Flash CGI */
+ if ( m_bbstype == Kita::Board_FlashCGI ) {
+ if ( title.contains( "ERROR!!" ) ) {
+ return K2ch_Error;
+ } else {
+ return K2ch_True;
}
+ }
- /* for JBBS. adhoc... */
- else if ( m_bbstype == Kita::Board_JBBS ) {
+ /* for JBBS. adhoc... */
+ if ( m_bbstype == Kita::Board_JBBS ) {
- // x-euc-jp & euc-jp
- if ( response.contains( "euc-jp" ) ) retcode = K2ch_True;
- else retcode = K2ch_Error;
+ // x-euc-jp & euc-jp
+ if ( response.contains( "euc-jp" ) ) {
+ return K2ch_True;
+ } else {
+ return K2ch_Error;
}
}
+
+ return K2ch_Unknown;
}
-
- return retcode;
}