Blob Blame History Raw
--- kita-0.177.4/kita/src/write/writeview.cpp.cookie	2008-09-16 21:56:03.000000000 +0900
+++ kita-0.177.4/kita/src/write/writeview.cpp	2008-09-16 22:41:39.000000000 +0900
@@ -43,6 +43,9 @@
 #include <qcheckbox.h>
 #include <qlayout.h>
 
+#include <cstring>
+#include <cstdlib>
+
 /* result code */
 enum{
     K2ch_Unknown,
@@ -191,6 +194,10 @@
     for ( it = list.begin(); it != list.end(); ++it ) {
         faceCombo->insertItem( *it );
     }
+
+    cookie_type = NULL;
+    cookie_value = NULL;
+
 }
 
 
@@ -344,12 +351,48 @@
     m_array.append( data.data() );
 }
 
+void KitaWriteView::find_cookie_typevalue( const char *response ){
+	char *str_cmp, *str;
+	static char *cookie_type_static = NULL;
+	static char *cookie_value_static = NULL;
+	cookie_type = cookie_value = NULL;
+
+	str_cmp = "<input type=hidden name=\"";
+	str = strstr(response, str_cmp);
+	if (str){
+		char *str2 = strstr(str, "\"");
+		char *str3 = NULL;
+		str2++;
+		if ((!cookie_type_static) || (!(strstr(str2, cookie_type_static)))){
+			free(cookie_type_static);
+			free(cookie_value_static);
+
+			cookie_type_static = strdup(str2);
+			str3 = strstr(cookie_type_static, "\"");
+			*str3 = 0;
+
+			str = str2;
+			str2 = strstr(str, "value=\"");
+			str = str2;
+			str2 = strstr(str, "\"");
+			str2++;
+			cookie_value_static = strdup(str2);
+			str3 = strstr(cookie_value_static, "\"");
+			*str3 = 0;
+		}
+	}
+	cookie_type = cookie_type_static;
+	cookie_value = cookie_value_static;
+}
+
+
 
 /* This slot is called when posting is done. */
 /* see also slotPostMessage()                */ /* private slot */
 void KitaWriteView::slotPostFinished( KIO::Job* )
 {
     QString response;
+    const char *response_ascii;
 
     // x-euc-jp & euc-jp
     if ( m_array.contains( "euc-jp" ) ) {
@@ -401,6 +444,9 @@
         /* eat cookie, then re-post message */
     case K2ch_Cookie:
 
+	response_ascii = (const char *) QString::fromLocal8Bit(response).utf8();
+	find_cookie_typevalue(response_ascii);
+
         if ( KMessageBox::questionYesNo( 0,
                                          QTextCodec::codecForName( "utf8" ) ->toUnicode( KITAUTF8_WRITECOOKIEMSG ),
                                          resultTitle( response ) )
@@ -510,6 +556,12 @@
     ( ret += "&MESSAGE=" ) += KURL::encode_string( bodyText->text(), mib );
     ( ret += "&bbs=" ) += Kita::BoardManager::boardID( m_datURL );
     ( ret += "&suka=pontan" );
+    if (cookie_type){
+	ret += "&";
+	ret += cookie_type;
+	ret += "=";
+	ret += cookie_value;
+    }
 
     /* key */
     if ( m_mode == WRITEMODE_NORMAL ) ( ret += "&key=" ) += Kita::DatManager::threadID( m_datURL );
--- kita-0.177.4/kita/src/write/writeview.h.cookie	2005-05-03 13:10:26.000000000 +0900
+++ kita-0.177.4/kita/src/write/writeview.h	2008-09-16 22:41:30.000000000 +0900
@@ -45,6 +45,9 @@
 
     static QCp932Codec* m_cp932Codec;
 
+    char *cookie_type;
+    char *cookie_value;
+
 public:
 
     KitaWriteView( QWidget* parent, const char* name, const KURL& url, int mode, const QString& newThreadName = QString::null );
@@ -70,6 +73,7 @@
     void slotRecieveData( KIO::Job*, const QByteArray& );
     void slotPostFinished( KIO::Job* );
     void slotCurrentChanged ( QWidget * w );
+    void find_cookie_typevalue( const char *response );
     bool slotBodyTextChanged();
 
 private: