summaryrefslogtreecommitdiffabout
path: root/kmicromail
authorzautrix <zautrix>2004-09-16 15:13:40 (UTC)
committer zautrix <zautrix>2004-09-16 15:13:40 (UTC)
commit02e7ae4983679a787834277176a031286a8310c2 (patch) (unidiff)
treeea7e33e59b86b8fed2b033609d1018a9f245baff /kmicromail
parent68b1f3bce4b6e89bb343b965256537d93e63f7be (diff)
downloadkdepimpi-02e7ae4983679a787834277176a031286a8310c2.zip
kdepimpi-02e7ae4983679a787834277176a031286a8310c2.tar.gz
kdepimpi-02e7ae4983679a787834277176a031286a8310c2.tar.bz2
Foldername fixes
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/accountitem.cpp2
-rw-r--r--kmicromail/libmailwrapper/mailwrapper.cpp7
-rw-r--r--kmicromail/libmailwrapper/mailwrapper.h2
3 files changed, 6 insertions, 5 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp
index 59c8abb..12d047a 100644
--- a/kmicromail/accountitem.cpp
+++ b/kmicromail/accountitem.cpp
@@ -450,97 +450,97 @@ void IMAPviewItem::refresh(QValueList<RecMailP>&)
450{ 450{
451 refreshFolders(false); 451 refreshFolders(false);
452} 452}
453 453
454const QStringList&IMAPviewItem::subFolders() 454const QStringList&IMAPviewItem::subFolders()
455{ 455{
456 return currentFolders; 456 return currentFolders;
457} 457}
458 458
459void IMAPviewItem::refreshFolders(bool force) 459void IMAPviewItem::refreshFolders(bool force)
460{ 460{
461 if (childCount()>0 && force==false) return; 461 if (childCount()>0 && force==false) return;
462 if (account->getOffline()) return; 462 if (account->getOffline()) return;
463 463
464 removeChilds(); 464 removeChilds();
465 currentFolders.clear(); 465 currentFolders.clear();
466 QValueList<FolderP> * folders = wrapper->listFolders(); 466 QValueList<FolderP> * folders = wrapper->listFolders();
467 467
468 QValueList<FolderP>::Iterator it; 468 QValueList<FolderP>::Iterator it;
469 QListViewItem*item = 0; 469 QListViewItem*item = 0;
470 QListViewItem*titem = 0; 470 QListViewItem*titem = 0;
471 QString fname,del,search; 471 QString fname,del,search;
472 int pos; 472 int pos;
473 473
474 for ( it = folders->begin(); it!=folders->end(); ++it) 474 for ( it = folders->begin(); it!=folders->end(); ++it)
475 { 475 {
476 if ((*it)->getDisplayName().lower()=="inbox") 476 if ((*it)->getDisplayName().lower()=="inbox")
477 { 477 {
478 item = new IMAPfolderItem( (*it), this , item ); 478 item = new IMAPfolderItem( (*it), this , item );
479 folders->remove(it); 479 folders->remove(it);
480 break; 480 break;
481 } 481 }
482 } 482 }
483 for ( it = folders->begin(); it!=folders->end(); ++it) 483 for ( it = folders->begin(); it!=folders->end(); ++it)
484 { 484 {
485 fname = (*it)->getDisplayName(); 485 fname = (*it)->getDisplayName();
486 currentFolders.append((*it)->getName()); 486 currentFolders.append((*it)->getName());
487 pos = fname.findRev((*it)->Separator()); 487 pos = fname.findRev((*it)->Separator());
488 if (pos != -1) 488 if (pos != -1)
489 { 489 {
490 fname = fname.left(pos); 490 fname = fname.left(pos);
491 } 491 }
492 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); 492 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname);
493 if (pitem) 493 if (pitem)
494 { 494 {
495 titem = item; 495 titem = item;
496 item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); 496 item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this);
497 /* setup the short name */ 497 /* setup the short name */
498 item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); 498 item->setText(0,(*it)->getDisplayName().mid(pos+1));
499 item = titem; 499 item = titem;
500 } 500 }
501 else 501 else
502 { 502 {
503 item = new IMAPfolderItem( (*it), this , item ); 503 item = new IMAPfolderItem( (*it), this , item );
504 } 504 }
505 } 505 }
506 delete folders; 506 delete folders;
507} 507}
508 508
509QPopupMenu * IMAPviewItem::getContextMenu() 509QPopupMenu * IMAPviewItem::getContextMenu()
510{ 510{
511 QPopupMenu *m = new QPopupMenu(0); 511 QPopupMenu *m = new QPopupMenu(0);
512 if (m) 512 if (m)
513 { 513 {
514 if (!account->getOffline()) 514 if (!account->getOffline())
515 { 515 {
516 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 516 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
517 m->insertItem(QObject::tr("Create new folder",contextName),1); 517 m->insertItem(QObject::tr("Create new folder",contextName),1);
518 m->insertSeparator(); 518 m->insertSeparator();
519 m->insertItem(QObject::tr("Disconnect",contextName),2); 519 m->insertItem(QObject::tr("Disconnect",contextName),2);
520 m->insertItem(QObject::tr("Set offline",contextName),3); 520 m->insertItem(QObject::tr("Set offline",contextName),3);
521 m->insertSeparator(); 521 m->insertSeparator();
522 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); 522 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS);
523 } 523 }
524 else 524 else
525 { 525 {
526 m->insertItem(QObject::tr("Set online",contextName),3); 526 m->insertItem(QObject::tr("Set online",contextName),3);
527 m->insertSeparator(); 527 m->insertSeparator();
528 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS); 528 m->insertItem(QObject::tr("Get new messages",contextName),GET_NEW_MAILS);
529 } 529 }
530 } 530 }
531 return m; 531 return m;
532} 532}
533 533
534void IMAPviewItem::createNewFolder() 534void IMAPviewItem::createNewFolder()
535{ 535{
536 Newmdirdlg ndirdlg; 536 Newmdirdlg ndirdlg;
537 537
538 ndirdlg.showMaximized(); 538 ndirdlg.showMaximized();
539 if ( ndirdlg.exec() ) 539 if ( ndirdlg.exec() )
540 { 540 {
541 QString ndir = ndirdlg.Newdir(); 541 QString ndir = ndirdlg.Newdir();
542 bool makesubs = ndirdlg.subpossible(); 542 bool makesubs = ndirdlg.subpossible();
543 QString delemiter = "/"; 543 QString delemiter = "/";
544 IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); 544 IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
545 if (item) 545 if (item)
546 { 546 {
diff --git a/kmicromail/libmailwrapper/mailwrapper.cpp b/kmicromail/libmailwrapper/mailwrapper.cpp
index 9400649..2ee1ab3 100644
--- a/kmicromail/libmailwrapper/mailwrapper.cpp
+++ b/kmicromail/libmailwrapper/mailwrapper.cpp
@@ -1,101 +1,102 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <sys/stat.h> 2#include <sys/stat.h>
3#include <sys/types.h> 3#include <sys/types.h>
4#include <unistd.h> 4#include <unistd.h>
5#include <fcntl.h> 5#include <fcntl.h>
6#include <string.h> 6#include <string.h>
7#include <qdir.h> 7#include <qdir.h>
8 8
9#include "mailwrapper.h" 9#include "mailwrapper.h"
10//#include "logindialog.h" 10//#include "logindialog.h"
11//#include "defines.h" 11//#include "defines.h"
12 12
13#define UNDEFINED 64 13#define UNDEFINED 64
14#define MAXLINE 76 14#define MAXLINE 76
15#define UTF16MASK 0x03FFUL 15#define UTF16MASK 0x03FFUL
16#define UTF16SHIFT 10 16#define UTF16SHIFT 10
17#define UTF16BASE 0x10000UL 17#define UTF16BASE 0x10000UL
18#define UTF16HIGHSTART 0xD800UL 18#define UTF16HIGHSTART 0xD800UL
19#define UTF16HIGHEND 0xDBFFUL 19#define UTF16HIGHEND 0xDBFFUL
20#define UTF16LOSTART 0xDC00UL 20#define UTF16LOSTART 0xDC00UL
21#define UTF16LOEND 0xDFFFUL 21#define UTF16LOEND 0xDFFFUL
22 22
23 23
24using namespace Opie::Core; 24using namespace Opie::Core;
25Attachment::Attachment( QString lnk ) 25Attachment::Attachment( QString lnk )
26{ 26{
27 doc = lnk; 27 doc = lnk;
28 size = QFileInfo( doc ).size(); 28 size = QFileInfo( doc ).size();
29 mPix = SmallIcon( "files" ); 29 mPix = SmallIcon( "files" );
30} 30}
31 31
32Folder::Folder(const QString&tmp_name, const QString&sep ) 32Folder::Folder(const QString&tmp_name, const QString&sep )
33{ 33{
34 name = tmp_name; 34 name = tmp_name;
35 nameDisplay = name; 35 nameDisplay = name;
36 separator = sep; 36 separator = sep;
37 prefix = ""; 37 prefix = "";
38} 38}
39 39
40Folder::~Folder() 40Folder::~Folder()
41{ 41{
42} 42}
43 43
44const QString& Folder::Separator()const 44const QString& Folder::Separator()const
45{ 45{
46 return separator; 46 return separator;
47} 47}
48 48
49IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&aprefix ) 49IMAPFolder::IMAPFolder(const QString&t_name,const QString&sep, bool select,bool no_inf, const QString&aprefix )
50 : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf) 50 : Folder( t_name,sep ),m_MaySelect(select),m_NoInferior(no_inf)
51{ 51{
52 // Decode IMAP foldername 52 // Decode IMAP foldername
53 nameDisplay = IMAPFolder::decodeFolderName( name ); 53 nameDisplay = IMAPFolder::decodeFolderName( t_name );
54 name = nameDisplay ;
54 /* 55 /*
55 odebug << "folder " + name + " - displayed as " + nameDisplay << oendl; 56 odebug << "folder " + name + " - displayed as " + nameDisplay << oendl;
56 */ 57 */
57 prefix = aprefix; 58 prefix = aprefix;
58 59
59 if (prefix.length()>0) { 60 if (prefix.length()>0) {
60 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { 61 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) {
61 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); 62 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length());
62 } 63 }
63 } 64 }
64} 65}
65 66
66IMAPFolder::~IMAPFolder() 67IMAPFolder::~IMAPFolder()
67{ 68{
68} 69}
69 70
70static unsigned char base64chars[] = 71static unsigned char base64chars[] =
71 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; 72 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
72 73
73/** 74/**
74 * Decodes base64 encoded parts of the imapfolder name 75 * Decodes base64 encoded parts of the imapfolder name
75 * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc 76 * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc
76 */ 77 */
77QString IMAPFolder::decodeFolderName( const QString &name ) 78QString IMAPFolder::decodeFolderName( const QString &name )
78{ 79{
79 unsigned char c, i, bitcount; 80 unsigned char c, i, bitcount;
80 unsigned long ucs4, utf16, bitbuf; 81 unsigned long ucs4, utf16, bitbuf;
81 unsigned char base64[256], utf8[6]; 82 unsigned char base64[256], utf8[6];
82 unsigned long srcPtr = 0; 83 unsigned long srcPtr = 0;
83 QCString dst = ""; 84 QCString dst = "";
84 QCString src = name.ascii(); 85 QCString src = name.ascii();
85 86
86 /* initialize modified base64 decoding table */ 87 /* initialize modified base64 decoding table */
87 memset(base64, UNDEFINED, sizeof(base64)); 88 memset(base64, UNDEFINED, sizeof(base64));
88 for (i = 0; i < sizeof(base64chars); ++i) { 89 for (i = 0; i < sizeof(base64chars); ++i) {
89 base64[(int)base64chars[i]] = i; 90 base64[(int)base64chars[i]] = i;
90 } 91 }
91 92
92 /* loop until end of string */ 93 /* loop until end of string */
93 while (srcPtr < src.length ()) { 94 while (srcPtr < src.length ()) {
94 c = src[srcPtr++]; 95 c = src[srcPtr++];
95 /* deal with literal characters and &- */ 96 /* deal with literal characters and &- */
96 if (c != '&' || src[srcPtr] == '-') { 97 if (c != '&' || src[srcPtr] == '-') {
97 /* encode literally */ 98 /* encode literally */
98 dst += c; 99 dst += c;
99 /* skip over the '-' if this is an &- sequence */ 100 /* skip over the '-' if this is an &- sequence */
100 if (c == '&') 101 if (c == '&')
101 srcPtr++; 102 srcPtr++;
diff --git a/kmicromail/libmailwrapper/mailwrapper.h b/kmicromail/libmailwrapper/mailwrapper.h
index cefe64e..2ba908b 100644
--- a/kmicromail/libmailwrapper/mailwrapper.h
+++ b/kmicromail/libmailwrapper/mailwrapper.h
@@ -75,54 +75,54 @@ public:
75 void setBCC( const QString&s ) { bcc = s; } 75 void setBCC( const QString&s ) { bcc = s; }
76 const QString&getMessage()const { return message; } 76 const QString&getMessage()const { return message; }
77 void setMessage( const QString&s ) { message = s; } 77 void setMessage( const QString&s ) { message = s; }
78 const QString&getSubject()const { return subject; } 78 const QString&getSubject()const { return subject; }
79 void setSubject( const QString&s ) { subject = s; } 79 void setSubject( const QString&s ) { subject = s; }
80 const QString&getReply()const{ return reply; } 80 const QString&getReply()const{ return reply; }
81 void setReply( const QString&a ) { reply = a; } 81 void setReply( const QString&a ) { reply = a; }
82 void setInreply(const QStringList&list){m_in_reply_to = list;} 82 void setInreply(const QStringList&list){m_in_reply_to = list;}
83 const QStringList&Inreply()const{return m_in_reply_to;} 83 const QStringList&Inreply()const{return m_in_reply_to;}
84 84
85private: 85private:
86 QList<Attachment> attList; 86 QList<Attachment> attList;
87 QString name, mail, to, cc, bcc, reply, subject, message; 87 QString name, mail, to, cc, bcc, reply, subject, message;
88 QStringList m_in_reply_to; 88 QStringList m_in_reply_to;
89}; 89};
90 90
91class Folder:public Opie::Core::ORefCount 91class Folder:public Opie::Core::ORefCount
92{ 92{
93public: 93public:
94 Folder( const QString&init_name,const QString&sep ); 94 Folder( const QString&init_name,const QString&sep );
95 virtual ~Folder(); 95 virtual ~Folder();
96 const QString&getDisplayName()const { return nameDisplay; } 96 const QString&getDisplayName()const { return nameDisplay; }
97 const QString&getName()const { return name; } 97 const QString&getName()const { return name; }
98 const QString&getPrefix()const{return prefix; } 98 const QString&getPrefix()const{return prefix; }
99 virtual bool may_select()const{return true;} 99 virtual bool may_select()const{return true;}
100 virtual bool no_inferior()const{return true;} 100 virtual bool no_inferior()const{return true;}
101 const QString&Separator()const; 101 const QString&Separator()const;
102 102
103protected: 103protected:
104 QString nameDisplay, name, separator,prefix; 104 QString nameDisplay, name, separator,prefix;
105}; 105};
106 106
107typedef Opie::Core::OSmartPointer<Folder> FolderP; 107typedef Opie::Core::OSmartPointer<Folder> FolderP;
108 108
109class MHFolder : public Folder 109class MHFolder : public Folder
110{ 110{
111public: 111public:
112 MHFolder(const QString&disp_name,const QString&mbox); 112 MHFolder(const QString&disp_name,const QString&mbox);
113 virtual ~MHFolder(); 113 virtual ~MHFolder();
114}; 114};
115 115
116class IMAPFolder : public Folder 116class IMAPFolder : public Folder
117{ 117{
118 public: 118 public:
119 IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); 119 IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" );
120 virtual ~IMAPFolder(); 120 virtual ~IMAPFolder();
121 virtual bool may_select()const{return m_MaySelect;} 121 virtual bool may_select()const{return m_MaySelect;}
122 virtual bool no_inferior()const{return m_NoInferior;} 122 virtual bool no_inferior()const{return m_NoInferior;}
123 private:
124 static QString decodeFolderName( const QString &name ); 123 static QString decodeFolderName( const QString &name );
124 private:
125 bool m_MaySelect,m_NoInferior; 125 bool m_MaySelect,m_NoInferior;
126}; 126};
127 127
128#endif 128#endif