summaryrefslogtreecommitdiff
authorconber <conber>2002-06-15 10:25:10 (UTC)
committer conber <conber>2002-06-15 10:25:10 (UTC)
commit95af3cd6c1a68ddd9200d4f7e25baf5c560f071c (patch) (side-by-side diff)
treec24008f1524e137b42d8762e2b73f353e17c9824
parent46a46dde707b08e1422757df00b1fb1941e49d4f (diff)
downloadopie-95af3cd6c1a68ddd9200d4f7e25baf5c560f071c.zip
opie-95af3cd6c1a68ddd9200d4f7e25baf5c560f071c.tar.gz
opie-95af3cd6c1a68ddd9200d4f7e25baf5c560f071c.tar.bz2
changed include error
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/mail2/libmail/miscfunctions.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/noncore/unsupported/mail2/libmail/miscfunctions.cpp b/noncore/unsupported/mail2/libmail/miscfunctions.cpp
index 0edbfa8..c81b101 100644
--- a/noncore/unsupported/mail2/libmail/miscfunctions.cpp
+++ b/noncore/unsupported/mail2/libmail/miscfunctions.cpp
@@ -1,201 +1,200 @@
#include <qdatetime.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
-#include <openssl/md5.h>
-
#include "miscfunctions.h"
+#include "md5.h"
QString MiscFunctions::encodeQPrintable(const QString &src)
{
// TODO: implent encodeQPrintable
return src;
}
QString MiscFunctions::decodeQPrintable(const QString &src)
{
QString out;
for (unsigned int i = 0; i <= src.length(); i++) {
if (src[i] == '=') {
if (src[i+1] == "\n") {
i += 1;
} else {
QString temp = QString("%1%2").arg(src[i+1]).arg(src[i+2]);
int number = temp.toInt(0, 16);
out += QChar(number);
i += 2;
}
} else {
out += src[i];
}
}
return out;
}
QString MiscFunctions::encodeBase64(const QString &src)
{
char *dataPtr = (char *) src.latin1();
int len = src.length();
int count = 0;
QString temp = "";
while (len > 0) {
if (len < 3) {
encodeBase64Base(dataPtr, &temp, len);
len = 0;
} else {
encodeBase64Base(dataPtr, &temp, 3);
len -= 3;
dataPtr += 3;
count += 4;
}
if (count > 72) {
count = 0;
temp += "\n";
}
}
return temp;
}
void MiscFunctions::encodeBase64Base(char *src, QString *dest, int len)
{
QString temp;
uchar c;
uchar bufOut[4];
bufOut[0] = src[0];
bufOut[0] >>= 2;
bufOut[1] = src[0];
bufOut[1] = bufOut[1] & (1 + 2);
bufOut[1] <<= 4;
if (len > 1) c = src[1];
else c = 0;
c = c & (16 + 32 + 64 + 128);
c >>= 4;
bufOut[1] = bufOut[1] | c;
bufOut[2] = src[1];
bufOut[2] = bufOut[2] & (1 + 2 + 4 + 8);
bufOut[2] <<= 2;
if (len > 2) c = src[2];
else c = 0;
c >>= 6;
bufOut[2] = bufOut[2] | c;
bufOut[3] = src[2];
bufOut[3] = bufOut[3] & (1 + 2 + 4 + 8 + 16 + 32);
if (len == 1) {
bufOut[2] = 64;
bufOut[3] = 64;
}
if (len == 2) {
bufOut[3] = 64;
}
for (int x = 0; x < 4; x++) {
if (bufOut[x] <= 25)
bufOut[x] += (uint) 'A';
else if (bufOut[x] >= 26 && bufOut[x] <= 51)
bufOut[x] += (uint) 'a' - 26;
else if (bufOut[x] >= 52 && bufOut[x] <= 61)
bufOut[x] += (uint) '0' - 52;
else if (bufOut[x] == 62)
bufOut[x] = '+';
else if (bufOut[x] == 63)
bufOut[x] = '/';
else if (bufOut[x] == 64)
bufOut[x] = '=';
dest->append(bufOut[x]);
}
}
QString MiscFunctions::decodeBase64(const QString &src)
{
char plain[4];
char *destPtr;
QByteArray buffer;
uint bufCount = 0, pos = 0, decodedCount, x;
buffer.resize(src.length() * 3 / 4);
destPtr = buffer.data();
while (pos < src.length()) {
decodedCount = 4;
x = 0;
while ((x < 4) && (pos < src.length())) {
plain[x] = src[pos].latin1();
pos++;
if (plain[x] == '\r' || plain[x] == '\n' || plain[x] == ' ')
x--;
x++;
}
if (x > 1) {
decodedCount = decodeBase64Base(plain, destPtr);
destPtr += decodedCount;
bufCount += decodedCount;
}
}
buffer.resize(bufCount);
return QString(buffer);
}
int MiscFunctions::decodeBase64Base(char *src, char *bufOut)
{
char c, z;
char li[4];
int processed;
for (int x = 0; x < 4; x++) {
c = src[x];
if ( (int) c >= 'A' && (int) c <= 'Z')
li[x] = (int) c - (int) 'A';
if ( (int) c >= 'a' && (int) c <= 'z')
li[x] = (int) c - (int) 'a' + 26;
if ( (int) c >= '0' && (int) c <= '9')
li[x] = (int) c - (int) '0' + 52;
if (c == '+')
li[x] = 62;
if (c == '/')
li[x] = 63;
}
processed = 1;
bufOut[0] = (char) li[0] & (32+16+8+4+2+1);
bufOut[0] <<= 2;
z = li[1] >> 4;
bufOut[0] = bufOut[0] | z;
if (src[2] != '=') {
bufOut[1] = (char) li[1] & (8+4+2+1);
bufOut[1] <<= 4;
z = li[2] >> 2;
bufOut[1] = bufOut[1] | z;
processed++;
if (src[3] != '=') {
bufOut[2] = (char) li[2] & (2+1);
bufOut[2] <<= 6;
z = li[3];
bufOut[2] = bufOut[2] | z;
processed++;
}
}
return processed;
}
QString MiscFunctions::uniqueString()
{
QString uniqueString = QDate::currentDate().toString();
uniqueString += QTime::currentTime().toString();
uniqueString += QString("%1").arg(rand());