[Kst] kdeextragear-2/kst/kst/extensions/elog

George Staikos staikos at kde.org
Thu Oct 7 15:08:50 CEST 2004


CVS commit by staikos: 

use KCodecs::base64Encode
(I can't actually test this, just send me a note if it breaks anything)


  M +4 -40     elogthread.cpp   1.10


--- kdeextragear-2/kst/kst/extensions/elog/elogthread.cpp  #1.9:1.10
@@ -38,6 +38,7 @@
 
 #include <kaction.h>
-#include <kmessagebox.h>
+#include <kmdcodec.h>
 #include <kmdimainfrm.h>
+#include <kmessagebox.h>
 #include <ksockaddr.h>
 
@@ -55,39 +56,4 @@ ElogThread::~ElogThread() {
 }
 
-// FIXME: replace with KCodecs::base64Encode()
-void ElogThread::base64_encode( const char *s, char *d )
-{
-  static char map[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-  unsigned int t, pad;
-
-  pad = 3 - strlen(s) % 3;
-  if (pad == 3) {
-    pad = 0;
-  }
-  while (*s) {
-    t = (*s++) << 16;
-    if (*s) {
-      t |= (*s++) << 8;
-    }
-    if (*s) {
-      t |= (*s++) << 0;
-    }
-    
-    *(d + 3) = map[t & 63];
-    t >>= 6;
-    *(d + 2) = map[t & 63];
-    t >>= 6;
-    *(d + 1) = map[t & 63];
-    t >>= 6;
-    *(d + 0) = map[t & 63];
-    
-    d += 4;
-  }
-  *d = 0;
-  while (pad--) {
-    *(--d) = '=';
-  }
-}
-
 void ElogThread::addAttachment( int* piContentLength,
                                 char** pp,
@@ -116,12 +82,10 @@ void ElogThread::addAttribute( char* con
                                const QString& strValue, 
                                bool bEncode ) {
-  char str[80];
-  
   if (!strValue.isEmpty()) {
     if( bEncode ) {
-      base64_encode(strValue.ascii(), str);
+      QCString enc = KCodecs::base64Encode(strValue.latin1());
       sprintf(content + strlen(content),
               "%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n",
-              boundary, tag, str);
+              boundary, tag, enc.data());
     } else {
       sprintf(content + strlen(content),





More information about the Kst mailing list