-rw-r--r-- | noncore/net/mailit/addresslist.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mailit/emailhandler.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mailit/mailitwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/net/mailit/popclient.cpp | 10 | ||||
-rw-r--r-- | noncore/net/mailit/readmail.cpp | 1 | ||||
-rw-r--r-- | noncore/net/mailit/smtpclient.cpp | 20 | ||||
-rw-r--r-- | noncore/unsupported/mailit/addresslist.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailclient.cpp | 8 | ||||
-rw-r--r-- | noncore/unsupported/mailit/emailhandler.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/mailit/mailitwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/unsupported/mailit/popclient.cpp | 10 | ||||
-rw-r--r-- | noncore/unsupported/mailit/readmail.cpp | 1 | ||||
-rw-r--r-- | noncore/unsupported/mailit/smtpclient.cpp | 20 |
14 files changed, 42 insertions, 50 deletions
diff --git a/noncore/net/mailit/addresslist.cpp b/noncore/net/mailit/addresslist.cpp index 9fe558a..8d9ab91 100644 --- a/noncore/net/mailit/addresslist.cpp +++ b/noncore/net/mailit/addresslist.cpp | |||
@@ -34,128 +34,128 @@ AddressList::AddressList() | |||
34 | AddressList::~AddressList() | 34 | AddressList::~AddressList() |
35 | { | 35 | { |
36 | addresses.clear(); | 36 | addresses.clear(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void AddressList::addContact(QString email, QString name) | 39 | void AddressList::addContact(QString email, QString name) |
40 | { | 40 | { |
41 | //skip if not a valid email address, | 41 | //skip if not a valid email address, |
42 | if (email.find( '@') == -1) | 42 | if (email.find( '@') == -1) |
43 | return; | 43 | return; |
44 | 44 | ||
45 | if ( ! containsEmail(email) ) { | 45 | if ( ! containsEmail(email) ) { |
46 | Contact *in = new Contact; | 46 | Contact *in = new Contact; |
47 | in->email = email; | 47 | in->email = email; |
48 | in->name = name; | 48 | in->name = name; |
49 | addresses.append(in); | 49 | addresses.append(in); |
50 | dirty = TRUE; | 50 | dirty = TRUE; |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | bool AddressList::containsEmail(QString email) | 54 | bool AddressList::containsEmail(QString email) |
55 | { | 55 | { |
56 | return ( getEmailRef(email) != -1 ); | 56 | return ( getEmailRef(email) != -1 ); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool AddressList::containsName(QString name) | 59 | bool AddressList::containsName(QString name) |
60 | { | 60 | { |
61 | return ( getNameRef(name) != -1 ); | 61 | return ( getNameRef(name) != -1 ); |
62 | } | 62 | } |
63 | 63 | ||
64 | QString AddressList::getNameByEmail(QString email) | 64 | QString AddressList::getNameByEmail(QString email) |
65 | { | 65 | { |
66 | int pos = getEmailRef(email); | 66 | int pos = getEmailRef(email); |
67 | if (pos != -1) { | 67 | if (pos != -1) { |
68 | Contact *ptr = addresses.at(pos); | 68 | Contact *ptr = addresses.at(pos); |
69 | return ptr->name; | 69 | return ptr->name; |
70 | } | 70 | } |
71 | 71 | ||
72 | return NULL; | 72 | return NULL; |
73 | } | 73 | } |
74 | 74 | ||
75 | QString AddressList::getEmailByName(QString name) | 75 | QString AddressList::getEmailByName(QString name) |
76 | { | 76 | { |
77 | int pos = getNameRef(name); | 77 | int pos = getNameRef(name); |
78 | if (pos != -1) { | 78 | if (pos != -1) { |
79 | Contact *ptr = addresses.at(pos); | 79 | Contact *ptr = addresses.at(pos); |
80 | return ptr->email; | 80 | return ptr->email; |
81 | } | 81 | } |
82 | 82 | ||
83 | return NULL; | 83 | return NULL; |
84 | } | 84 | } |
85 | 85 | ||
86 | int AddressList::getEmailRef(QString email) | 86 | int AddressList::getEmailRef(QString email) |
87 | { | 87 | { |
88 | int pos = 0; | 88 | int pos = 0; |
89 | Contact *ptr; | 89 | Contact *ptr; |
90 | 90 | ||
91 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { | 91 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { |
92 | if (ptr->email == email) | 92 | if (ptr->email == email) |
93 | return pos; | 93 | return pos; |
94 | pos++; | 94 | pos++; |
95 | } | 95 | } |
96 | return -1; | 96 | return -1; |
97 | } | 97 | } |
98 | 98 | ||
99 | int AddressList::getNameRef(QString name) | 99 | int AddressList::getNameRef(QString name) |
100 | { | 100 | { |
101 | int pos = 0; | 101 | int pos = 0; |
102 | Contact *ptr; | 102 | Contact *ptr; |
103 | 103 | ||
104 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { | 104 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { |
105 | if (ptr->name == name) | 105 | if (ptr->name == name) |
106 | return pos; | 106 | return pos; |
107 | pos++; | 107 | pos++; |
108 | } | 108 | } |
109 | return -1; | 109 | return -1; |
110 | } | 110 | } |
111 | 111 | ||
112 | QList<Contact>* AddressList::getContactList() | 112 | QList<Contact>* AddressList::getContactList() |
113 | { | 113 | { |
114 | return &addresses; | 114 | return &addresses; |
115 | } | 115 | } |
116 | 116 | ||
117 | void AddressList::read() | 117 | void AddressList::read() |
118 | { | 118 | { |
119 | OContactAccess::List::Iterator it; | 119 | OContactAccess::List::Iterator it; |
120 | 120 | ||
121 | QString lineEmail, lineName, email, name; | 121 | QString lineEmail, lineName, email, name; |
122 | OContactAccess m_contactdb("mailit"); | 122 | OContactAccess m_contactdb("mailit"); |
123 | OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); | 123 | OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); |
124 | //OContact* oc; | 124 | //OContact* oc; |
125 | 125 | ||
126 | for ( it = m_list.begin(); it != m_list.end(); ++it ) | 126 | for ( it = m_list.begin(); it != m_list.end(); ++it ) |
127 | { | 127 | { |
128 | //oc=(OContact*) it; | 128 | //oc=(OContact*) it; |
129 | if ((*it).defaultEmail().length()!=0) | 129 | if ((*it).defaultEmail().length()!=0) |
130 | addContact((*it).defaultEmail(),(*it).fullName()); | 130 | addContact((*it).defaultEmail(),(*it).fileAs()); |
131 | } | 131 | } |
132 | 132 | ||
133 | /*if (! f.open(IO_ReadOnly) ) | 133 | /*if (! f.open(IO_ReadOnly) ) |
134 | return; | 134 | return; |
135 | 135 | ||
136 | QTextStream stream(&f); | 136 | QTextStream stream(&f); |
137 | 137 | ||
138 | while (! stream.atEnd() ) { | 138 | while (! stream.atEnd() ) { |
139 | lineEmail = stream.readLine(); | 139 | lineEmail = stream.readLine(); |
140 | if (! stream.atEnd() ) | 140 | if (! stream.atEnd() ) |
141 | lineName = stream.readLine(); | 141 | lineName = stream.readLine(); |
142 | else return; | 142 | else return; |
143 | 143 | ||
144 | email = getRightString(lineEmail); | 144 | email = getRightString(lineEmail); |
145 | name = getRightString(lineName); | 145 | name = getRightString(lineName); |
146 | addContact(email, name); | 146 | addContact(email, name); |
147 | } | 147 | } |
148 | f.close();*/ | 148 | f.close();*/ |
149 | } | 149 | } |
150 | 150 | ||
151 | QString AddressList::getRightString(QString in) | 151 | QString AddressList::getRightString(QString in) |
152 | { | 152 | { |
153 | QString out = ""; | 153 | QString out = ""; |
154 | 154 | ||
155 | int pos = in.find('='); | 155 | int pos = in.find('='); |
156 | if (pos != -1) { | 156 | if (pos != -1) { |
157 | out = in.mid(pos+1).stripWhiteSpace(); | 157 | out = in.mid(pos+1).stripWhiteSpace(); |
158 | } | 158 | } |
159 | return out; | 159 | return out; |
160 | } | 160 | } |
161 | 161 | ||
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 6612541..0d82a9a 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp | |||
@@ -439,252 +439,252 @@ void EmailClient::allMailArrived(int count) | |||
439 | } | 439 | } |
440 | 440 | ||
441 | // all headers downloaded from server, start downloading remaining mails | 441 | // all headers downloaded from server, start downloading remaining mails |
442 | previewingMail = FALSE; | 442 | previewingMail = FALSE; |
443 | status1Label->setText(currentAccount->accountName); | 443 | status1Label->setText(currentAccount->accountName); |
444 | progressBar->reset(); | 444 | progressBar->reset(); |
445 | 445 | ||
446 | emailHandler->getMailByList(&mailDownloadList); | 446 | emailHandler->getMailByList(&mailDownloadList); |
447 | } | 447 | } |
448 | 448 | ||
449 | void EmailClient::moveMailFront(Email *mailPtr) | 449 | void EmailClient::moveMailFront(Email *mailPtr) |
450 | { | 450 | { |
451 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { | 451 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { |
452 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); | 452 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); |
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | void EmailClient::smtpError(int code) | 456 | void EmailClient::smtpError(int code) |
457 | { | 457 | { |
458 | QString temp; | 458 | QString temp; |
459 | 459 | ||
460 | if (code == ErrUnknownResponse) | 460 | if (code == ErrUnknownResponse) |
461 | temp = "Unknown response from server"; | 461 | temp = "Unknown response from server"; |
462 | 462 | ||
463 | if (code == QSocket::ErrHostNotFound) | 463 | if (code == QSocket::ErrHostNotFound) |
464 | temp = "host not found"; | 464 | temp = "host not found"; |
465 | if (code == QSocket::ErrConnectionRefused) | 465 | if (code == QSocket::ErrConnectionRefused) |
466 | temp = "connection refused"; | 466 | temp = "connection refused"; |
467 | if (code == QSocket::ErrSocketRead) | 467 | if (code == QSocket::ErrSocketRead) |
468 | temp = "socket packet error"; | 468 | temp = "socket packet error"; |
469 | 469 | ||
470 | if (code != ErrCancel) { | 470 | if (code != ErrCancel) { |
471 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); | 471 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); |
472 | } else { | 472 | } else { |
473 | status2Label->setText("Aborted by user"); | 473 | status2Label->setText("Aborted by user"); |
474 | } | 474 | } |
475 | 475 | ||
476 | sending = FALSE; | 476 | sending = FALSE; |
477 | sendMailButton->setEnabled(TRUE); | 477 | sendMailButton->setEnabled(TRUE); |
478 | cancelButton->setEnabled(FALSE); | 478 | cancelButton->setEnabled(FALSE); |
479 | quedMessages.clear(); | 479 | quedMessages.clear(); |
480 | } | 480 | } |
481 | 481 | ||
482 | void EmailClient::popError(int code) | 482 | void EmailClient::popError(int code) |
483 | { | 483 | { |
484 | QString temp; | 484 | QString temp; |
485 | 485 | ||
486 | if (code == ErrUnknownResponse) | 486 | if (code == ErrUnknownResponse) |
487 | temp = "Unknown response from server"; | 487 | temp = "Unknown response from server"; |
488 | if (code == ErrLoginFailed) | 488 | if (code == ErrLoginFailed) |
489 | temp = "Login failed\nCheck user name and password"; | 489 | temp = "Login failed\nCheck user name and password"; |
490 | 490 | ||
491 | if (code == QSocket::ErrHostNotFound) | 491 | if (code == QSocket::ErrHostNotFound) |
492 | temp = "host not found"; | 492 | temp = "host not found"; |
493 | if (code == QSocket::ErrConnectionRefused) | 493 | if (code == QSocket::ErrConnectionRefused) |
494 | temp = "connection refused"; | 494 | temp = "connection refused"; |
495 | if (code == QSocket::ErrSocketRead) | 495 | if (code == QSocket::ErrSocketRead) |
496 | temp = "socket packet error"; | 496 | temp = "socket packet error"; |
497 | 497 | ||
498 | if (code != ErrCancel) { | 498 | if (code != ErrCancel) { |
499 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); | 499 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); |
500 | } else { | 500 | } else { |
501 | status2Label->setText("Aborted by user"); | 501 | status2Label->setText("Aborted by user"); |
502 | } | 502 | } |
503 | 503 | ||
504 | receiving = FALSE; | 504 | receiving = FALSE; |
505 | getMailButton->setEnabled(TRUE); | 505 | getMailButton->setEnabled(TRUE); |
506 | cancelButton->setEnabled(FALSE); | 506 | cancelButton->setEnabled(FALSE); |
507 | selectAccountMenu->setEnabled(TRUE); | 507 | selectAccountMenu->setEnabled(TRUE); |
508 | } | 508 | } |
509 | 509 | ||
510 | void EmailClient::inboxItemSelected() | 510 | void EmailClient::inboxItemSelected() |
511 | { | 511 | { |
512 | item = (EmailListItem*) inboxView->selectedItem(); | 512 | item = (EmailListItem*) inboxView->selectedItem(); |
513 | if (item != NULL) { | 513 | if (item != NULL) { |
514 | emit viewEmail(inboxView, item->getMail()); | 514 | emit viewEmail(inboxView, item->getMail()); |
515 | } | 515 | } |
516 | } | 516 | } |
517 | 517 | ||
518 | void EmailClient::outboxItemSelected() | 518 | void EmailClient::outboxItemSelected() |
519 | { | 519 | { |
520 | item = (EmailListItem*) outboxView->selectedItem(); | 520 | item = (EmailListItem*) outboxView->selectedItem(); |
521 | if (item != NULL) { | 521 | if (item != NULL) { |
522 | emit viewEmail(outboxView, item->getMail()); | 522 | emit viewEmail(outboxView, item->getMail()); |
523 | } | 523 | } |
524 | 524 | ||
525 | } | 525 | } |
526 | 526 | ||
527 | void EmailClient::readMail() | 527 | void EmailClient::readMail() |
528 | { | 528 | { |
529 | Email mail; | 529 | Email mail; |
530 | int start, stop; | 530 | int start, stop; |
531 | QString s, del; | 531 | QString s, del; |
532 | 532 | ||
533 | QFile f(getPath(FALSE) + "inbox.txt"); | 533 | QFile f(getPath(FALSE) + "inbox.txt"); |
534 | // QFileInfo fi(f); | 534 | // QFileInfo fi(f); |
535 | qDebug( f.name()); | 535 | //qDebug( f.name()); |
536 | 536 | ||
537 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 537 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
538 | QTextStream t( &f ); // use a text stream | 538 | QTextStream t( &f ); // use a text stream |
539 | s = t.read(); | 539 | s = t.read(); |
540 | f.close(); | 540 | f.close(); |
541 | 541 | ||
542 | start = 0; | 542 | start = 0; |
543 | del = "\n.\n"; | 543 | del = "\n.\n"; |
544 | while ((uint) start < s.length()) { | 544 | while ((uint) start < s.length()) { |
545 | stop = s.find(del, start); | 545 | stop = s.find(del, start); |
546 | if (stop == -1) | 546 | if (stop == -1) |
547 | stop = s.length() - del.length(); | 547 | stop = s.length() - del.length(); |
548 | 548 | ||
549 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 549 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
550 | start = stop + del.length(); | 550 | start = stop + del.length(); |
551 | mailArrived(mail, TRUE); | 551 | mailArrived(mail, TRUE); |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | QFile fo(getPath(FALSE) + "outbox.txt"); | 555 | QFile fo(getPath(FALSE) + "outbox.txt"); |
556 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully | 556 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully |
557 | QTextStream t( &fo ); // use a text stream | 557 | QTextStream t( &fo ); // use a text stream |
558 | s = t.read(); | 558 | s = t.read(); |
559 | fo.close(); | 559 | fo.close(); |
560 | 560 | ||
561 | start = 0; | 561 | start = 0; |
562 | del = "\n.\n"; | 562 | del = "\n.\n"; |
563 | while ((uint) start < s.length()) { | 563 | while ((uint) start < s.length()) { |
564 | stop = s.find(del, start); | 564 | stop = s.find(del, start); |
565 | if (stop == -1) | 565 | if (stop == -1) |
566 | stop = s.length() - del.length(); | 566 | stop = s.length() - del.length(); |
567 | 567 | ||
568 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 568 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
569 | start = stop + del.length(); | 569 | start = stop + del.length(); |
570 | emailHandler->parse(mail.rawMail, lineShift, &mail); | 570 | emailHandler->parse(mail.rawMail, lineShift, &mail); |
571 | mail.sent = false; | 571 | mail.sent = false; |
572 | mail.received = false; | 572 | mail.received = false; |
573 | enqueMail(mail); | 573 | enqueMail(mail); |
574 | 574 | ||
575 | } | 575 | } |
576 | } | 576 | } |
577 | } | 577 | } |
578 | 578 | ||
579 | void EmailClient::saveMail(QString fileName, QListView *view) | 579 | void EmailClient::saveMail(QString fileName, QListView *view) |
580 | { | 580 | { |
581 | QFile f(fileName); | 581 | QFile f(fileName); |
582 | Email *mail; | 582 | Email *mail; |
583 | 583 | ||
584 | if (! f.open(IO_WriteOnly) ) { | 584 | if (! f.open(IO_WriteOnly) ) { |
585 | qWarning("could not open file"); | 585 | qWarning("could not open file"); |
586 | return; | 586 | return; |
587 | } | 587 | } |
588 | item = (EmailListItem *) view->firstChild(); | 588 | item = (EmailListItem *) view->firstChild(); |
589 | qDebug (QString("Write : ") ); | 589 | //qDebug (QString("Write : ") ); |
590 | QTextStream t(&f); | 590 | QTextStream t(&f); |
591 | while (item != NULL) { | 591 | while (item != NULL) { |
592 | mail = item->getMail(); | 592 | mail = item->getMail(); |
593 | qDebug(mail->rawMail); | 593 | //qDebug(mail->rawMail); |
594 | qDebug(mail->recipients.first()); | 594 | //qDebug(mail->recipients.first()); |
595 | t << mail->rawMail; | 595 | t << mail->rawMail; |
596 | 596 | ||
597 | mailconf->setGroup(mail->id); | 597 | mailconf->setGroup(mail->id); |
598 | mailconf->writeEntry("mailread", mail->read); | 598 | mailconf->writeEntry("mailread", mail->read); |
599 | 599 | ||
600 | item = (EmailListItem *) item->nextSibling(); | 600 | item = (EmailListItem *) item->nextSibling(); |
601 | } | 601 | } |
602 | f.close(); | 602 | f.close(); |
603 | } | 603 | } |
604 | 604 | ||
605 | //paths for mailit, is settings, inbox, enclosures | 605 | //paths for mailit, is settings, inbox, enclosures |
606 | QString EmailClient::getPath(bool enclosurePath) | 606 | QString EmailClient::getPath(bool enclosurePath) |
607 | { | 607 | { |
608 | QString basePath = "qtmail"; | 608 | QString basePath = "qtmail"; |
609 | QString enclosures = "enclosures"; | 609 | QString enclosures = "enclosures"; |
610 | 610 | ||
611 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); | 611 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); |
612 | if ( !dir.exists() ) | 612 | if ( !dir.exists() ) |
613 | dir.mkdir( dir.path() ); | 613 | dir.mkdir( dir.path() ); |
614 | 614 | ||
615 | if (enclosurePath) { | 615 | if (enclosurePath) { |
616 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); | 616 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); |
617 | 617 | ||
618 | if ( !dir.exists() ) | 618 | if ( !dir.exists() ) |
619 | dir.mkdir( dir.path() ); | 619 | dir.mkdir( dir.path() ); |
620 | 620 | ||
621 | return (dir.path() + "/"); | 621 | return (dir.path() + "/"); |
622 | 622 | ||
623 | } | 623 | } |
624 | return (dir.path() + "/"); | 624 | return (dir.path() + "/"); |
625 | } | 625 | } |
626 | 626 | ||
627 | void EmailClient::readSettings() | 627 | void EmailClient::readSettings() |
628 | { | 628 | { |
629 | TextParser *p; | 629 | TextParser *p; |
630 | QString s; | 630 | QString s; |
631 | int pos, accountPos, y; | 631 | int pos, accountPos, y; |
632 | QFile f( getPath(FALSE) + "settings.txt"); | 632 | QFile f( getPath(FALSE) + "settings.txt"); |
633 | 633 | ||
634 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 634 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
635 | QTextStream t( &f ); // use a text stream | 635 | QTextStream t( &f ); // use a text stream |
636 | s = t.read(); | 636 | s = t.read(); |
637 | f.close(); | 637 | f.close(); |
638 | 638 | ||
639 | p = new TextParser(s, "\n"); | 639 | p = new TextParser(s, "\n"); |
640 | 640 | ||
641 | accountPos = 0; | 641 | accountPos = 0; |
642 | while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { | 642 | while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { |
643 | accountPos++; | 643 | accountPos++; |
644 | if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) | 644 | if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) |
645 | account.accountName = p->getString(& ++pos, 'z', TRUE); | 645 | account.accountName = p->getString(& ++pos, 'z', TRUE); |
646 | if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) | 646 | if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) |
647 | account.name = p->getString(& ++pos, 'z', TRUE); | 647 | account.name = p->getString(& ++pos, 'z', TRUE); |
648 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) | 648 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) |
649 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); | 649 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); |
650 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) | 650 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) |
651 | account.popUserName = p->getString(& ++pos, 'z', TRUE); | 651 | account.popUserName = p->getString(& ++pos, 'z', TRUE); |
652 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) | 652 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) |
653 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); | 653 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); |
654 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) | 654 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) |
655 | account.popServer = p->getString(& ++pos, 'z', TRUE); | 655 | account.popServer = p->getString(& ++pos, 'z', TRUE); |
656 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) | 656 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) |
657 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); | 657 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); |
658 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { | 658 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { |
659 | s = p->getString(& ++pos, 'z', TRUE); | 659 | s = p->getString(& ++pos, 'z', TRUE); |
660 | account.id = s.toInt(); | 660 | account.id = s.toInt(); |
661 | } | 661 | } |
662 | 662 | ||
663 | account.lastServerMailCount = 0; | 663 | account.lastServerMailCount = 0; |
664 | account.synchronize = FALSE; | 664 | account.synchronize = FALSE; |
665 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { | 665 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { |
666 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { | 666 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { |
667 | account.synchronize = TRUE; | 667 | account.synchronize = TRUE; |
668 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { | 668 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { |
669 | s = p->getString(& ++pos, 'z', TRUE); | 669 | s = p->getString(& ++pos, 'z', TRUE); |
670 | account.lastServerMailCount = s.toInt(); | 670 | account.lastServerMailCount = s.toInt(); |
671 | } | 671 | } |
672 | } | 672 | } |
673 | } | 673 | } |
674 | 674 | ||
675 | if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { | 675 | if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { |
676 | account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); | 676 | account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); |
677 | } | 677 | } |
678 | 678 | ||
679 | 679 | ||
680 | accountList.append(&account); | 680 | accountList.append(&account); |
681 | } | 681 | } |
682 | delete p; | 682 | delete p; |
683 | } | 683 | } |
684 | mailconf->setGroup("mailitglobal"); | 684 | mailconf->setGroup("mailitglobal"); |
685 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { | 685 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { |
686 | mailIdCount = y; | 686 | mailIdCount = y; |
687 | } | 687 | } |
688 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { | 688 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { |
689 | accountIdCount = y; | 689 | accountIdCount = y; |
690 | } | 690 | } |
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp index 9c1c814..03f8a28 100644 --- a/noncore/net/mailit/emailhandler.cpp +++ b/noncore/net/mailit/emailhandler.cpp | |||
@@ -70,194 +70,192 @@ void EmailHandler::sendMail(QList<Email> *mailList) | |||
70 | Email *currentMail; | 70 | Email *currentMail; |
71 | QString temp; | 71 | QString temp; |
72 | QString userName = mailAccount.name; | 72 | QString userName = mailAccount.name; |
73 | userName += " <" + mailAccount.emailAddress + ">"; | 73 | userName += " <" + mailAccount.emailAddress + ">"; |
74 | 74 | ||
75 | for (currentMail = mailList->first(); currentMail != 0; | 75 | for (currentMail = mailList->first(); currentMail != 0; |
76 | currentMail = mailList->next()) { | 76 | currentMail = mailList->next()) { |
77 | 77 | ||
78 | if (encodeMime(currentMail) == 0) { | 78 | if (encodeMime(currentMail) == 0) { |
79 | smtpClient->addMail(userName, currentMail->subject, | 79 | smtpClient->addMail(userName, currentMail->subject, |
80 | currentMail->recipients, currentMail->rawMail); | 80 | currentMail->recipients, currentMail->rawMail); |
81 | } else { //error | 81 | } else { //error |
82 | temp = tr("Could not locate all files in \nmail with subject: ") + | 82 | temp = tr("Could not locate all files in \nmail with subject: ") + |
83 | currentMail->subject; | 83 | currentMail->subject; |
84 | temp += tr("\nMail has NOT been sent"); | 84 | temp += tr("\nMail has NOT been sent"); |
85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); | 85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); |
86 | 86 | ||
87 | } | 87 | } |
88 | } | 88 | } |
89 | smtpClient->newConnection(mailAccount.smtpServer, 25); | 89 | smtpClient->newConnection(mailAccount.smtpServer, 25); |
90 | } | 90 | } |
91 | 91 | ||
92 | void EmailHandler::setAccount(MailAccount account) | 92 | void EmailHandler::setAccount(MailAccount account) |
93 | { | 93 | { |
94 | mailAccount = account; | 94 | mailAccount = account; |
95 | } | 95 | } |
96 | 96 | ||
97 | void EmailHandler::getMail() | 97 | void EmailHandler::getMail() |
98 | { | 98 | { |
99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
100 | if (mailAccount.synchronize) { | 100 | if (mailAccount.synchronize) { |
101 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 101 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
102 | } else { | 102 | } else { |
103 | popClient->removeSynchronize(); | 103 | popClient->removeSynchronize(); |
104 | } | 104 | } |
105 | 105 | ||
106 | headers = FALSE; | 106 | headers = FALSE; |
107 | popClient->headersOnly(headers, 0); | 107 | popClient->headersOnly(headers, 0); |
108 | popClient->newConnection(mailAccount.popServer, 110); | 108 | popClient->newConnection(mailAccount.popServer, 110); |
109 | } | 109 | } |
110 | 110 | ||
111 | void EmailHandler::getMailHeaders() | 111 | void EmailHandler::getMailHeaders() |
112 | { | 112 | { |
113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
114 | if (mailAccount.synchronize) { | 114 | if (mailAccount.synchronize) { |
115 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 115 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
116 | } else { | 116 | } else { |
117 | popClient->removeSynchronize(); | 117 | popClient->removeSynchronize(); |
118 | } | 118 | } |
119 | 119 | ||
120 | headers = TRUE; | 120 | headers = TRUE; |
121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all | 121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all |
122 | popClient->newConnection(mailAccount.popServer, 110); | 122 | popClient->newConnection(mailAccount.popServer, 110); |
123 | } | 123 | } |
124 | 124 | ||
125 | void EmailHandler::getMailByList(MailList *mailList) | 125 | void EmailHandler::getMailByList(MailList *mailList) |
126 | { | 126 | { |
127 | if (mailList->count() == 0) { //should not occur though | 127 | if (mailList->count() == 0) { //should not occur though |
128 | emit mailTransfered(0); | 128 | emit mailTransfered(0); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | 131 | ||
132 | headers = FALSE; | 132 | headers = FALSE; |
133 | popClient->headersOnly(FALSE, 0); | 133 | popClient->headersOnly(FALSE, 0); |
134 | popClient->newConnection(mailAccount.popServer, 110); | 134 | popClient->newConnection(mailAccount.popServer, 110); |
135 | popClient->setSelectedMails(mailList); | 135 | popClient->setSelectedMails(mailList); |
136 | } | 136 | } |
137 | 137 | ||
138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) | 138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) |
139 | { | 139 | { |
140 | Email mail; | 140 | Email mail; |
141 | 141 | ||
142 | mail.rawMail = message; | 142 | mail.rawMail = message; |
143 | mail.serverId = id; | 143 | mail.serverId = id; |
144 | mail.size = size; | 144 | mail.size = size; |
145 | mail.downloaded = complete; | 145 | mail.downloaded = complete; |
146 | 146 | ||
147 | emit mailArrived(mail, FALSE); | 147 | emit mailArrived(mail, FALSE); |
148 | } | 148 | } |
149 | 149 | ||
150 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | 150 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) |
151 | { | 151 | { |
152 | QString temp, boundary; | 152 | QString temp, boundary; |
153 | int pos; | 153 | int pos; |
154 | QString delimiter, header, body, mimeHeader, mimeBody; | 154 | QString delimiter, header, body, mimeHeader, mimeBody; |
155 | QString content, contentType, contentAttribute, id, encoding; | 155 | QString content, contentType, contentAttribute, id, encoding; |
156 | QString fileName, storedName; | 156 | QString fileName, storedName; |
157 | int enclosureId = 0; | 157 | int enclosureId = 0; |
158 | 158 | ||
159 | mail->rawMail = in; | 159 | mail->rawMail = in; |
160 | mail->received = TRUE; | 160 | mail->received = TRUE; |
161 | mail->files.setAutoDelete(TRUE); | 161 | mail->files.setAutoDelete(TRUE); |
162 | 162 | ||
163 | temp = lineShift + "." + lineShift; | 163 | temp = lineShift + "." + lineShift; |
164 | 164 | ||
165 | if (in.right(temp.length()) != temp) { | 165 | if (in.right(temp.length()) != temp) { |
166 | qWarning(in.right(temp.length())); | ||
167 | qWarning(" . added at end of email as separator"); | ||
168 | mail->rawMail += temp; | 166 | mail->rawMail += temp; |
169 | } | 167 | } |
170 | 168 | ||
171 | 169 | ||
172 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" | 170 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" |
173 | pos = in.find(delimiter, 0, FALSE); | 171 | pos = in.find(delimiter, 0, FALSE); |
174 | header = in.left(pos); | 172 | header = in.left(pos); |
175 | body = in.right(in.length() - pos - delimiter.length()); | 173 | body = in.right(in.length() - pos - delimiter.length()); |
176 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) | 174 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) |
177 | body.truncate(body.length()-2); | 175 | body.truncate(body.length()-2); |
178 | 176 | ||
179 | TextParser p(header, lineShift); | 177 | TextParser p(header, lineShift); |
180 | 178 | ||
181 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { | 179 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { |
182 | pos++; | 180 | pos++; |
183 | if (p.separatorAt(pos) == ' ') { | 181 | if (p.separatorAt(pos) == ' ') { |
184 | mail->from = p.getString(&pos, '<', false); | 182 | mail->from = p.getString(&pos, '<', false); |
185 | mail->from = mail->from.stripWhiteSpace(); | 183 | mail->from = mail->from.stripWhiteSpace(); |
186 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { | 184 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { |
187 | mail->from = mail->from.left(mail->from.length() - 1); | 185 | mail->from = mail->from.left(mail->from.length() - 1); |
188 | mail->from = mail->from.right(mail->from.length() - 1); | 186 | mail->from = mail->from.right(mail->from.length() - 1); |
189 | } | 187 | } |
190 | pos++; | 188 | pos++; |
191 | mail->fromMail = p.getString(&pos, '>', false); | 189 | mail->fromMail = p.getString(&pos, '>', false); |
192 | } else { | 190 | } else { |
193 | if ((p.separatorAt(pos) == '<') | 191 | if ((p.separatorAt(pos) == '<') |
194 | || (p.separatorAt(pos) == ' ')) //No name.. nasty | 192 | || (p.separatorAt(pos) == ' ')) //No name.. nasty |
195 | pos++; | 193 | pos++; |
196 | pos++; | 194 | pos++; |
197 | mail->fromMail = p.getString(&pos, 'z', TRUE); | 195 | mail->fromMail = p.getString(&pos, 'z', TRUE); |
198 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | 196 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') |
199 | mail->fromMail.truncate(mail->fromMail.length() - 1); | 197 | mail->fromMail.truncate(mail->fromMail.length() - 1); |
200 | mail->from=mail->fromMail; | 198 | mail->from=mail->fromMail; |
201 | } | 199 | } |
202 | } | 200 | } |
203 | 201 | ||
204 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: | 202 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: |
205 | if (pos = p.find("TO",':', pos, TRUE) != -1) | 203 | if (pos = p.find("TO",':', pos, TRUE) != -1) |
206 | { | 204 | { |
207 | pos++; | 205 | pos++; |
208 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | 206 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); |
209 | } | 207 | } |
210 | 208 | ||
211 | 209 | ||
212 | 210 | ||
213 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { | 211 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { |
214 | pos++; | 212 | pos++; |
215 | mail->subject = p.getString(&pos, 'z', TRUE); | 213 | mail->subject = p.getString(&pos, 'z', TRUE); |
216 | } | 214 | } |
217 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { | 215 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { |
218 | pos++; | 216 | pos++; |
219 | mail->date = p.getString(&pos, 'z', true); | 217 | mail->date = p.getString(&pos, 'z', true); |
220 | } | 218 | } |
221 | 219 | ||
222 | 220 | ||
223 | 221 | ||
224 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { | 222 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { |
225 | pos++; | 223 | pos++; |
226 | if ( (p.wordAt(pos).upper() == "ID") && | 224 | if ( (p.wordAt(pos).upper() == "ID") && |
227 | (p.separatorAt(pos) == ':') ) { | 225 | (p.separatorAt(pos) == ':') ) { |
228 | 226 | ||
229 | id = p.getString(&pos, 'z', TRUE); | 227 | id = p.getString(&pos, 'z', TRUE); |
230 | mail->id = id; | 228 | mail->id = id; |
231 | } | 229 | } |
232 | } | 230 | } |
233 | 231 | ||
234 | pos = 0; | 232 | pos = 0; |
235 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { | 233 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { |
236 | pos++; | 234 | pos++; |
237 | if ( (p.wordAt(pos).upper() == "VERSION") && | 235 | if ( (p.wordAt(pos).upper() == "VERSION") && |
238 | (p.separatorAt(pos) == ':') ) { | 236 | (p.separatorAt(pos) == ':') ) { |
239 | pos++; | 237 | pos++; |
240 | if (p.getString(&pos, 'z', true) == "1.0") { | 238 | if (p.getString(&pos, 'z', true) == "1.0") { |
241 | mail->mimeType = 1; | 239 | mail->mimeType = 1; |
242 | } | 240 | } |
243 | } | 241 | } |
244 | } | 242 | } |
245 | 243 | ||
246 | if (mail->mimeType == 1) { | 244 | if (mail->mimeType == 1) { |
247 | boundary = ""; | 245 | boundary = ""; |
248 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { | 246 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { |
249 | pos++; | 247 | pos++; |
250 | boundary = p.getString(&pos, 'z', true); | 248 | boundary = p.getString(&pos, 'z', true); |
251 | if (boundary[0] == '"') { | 249 | if (boundary[0] == '"') { |
252 | boundary = boundary.left(boundary.length() - 1); //strip " | 250 | boundary = boundary.left(boundary.length() - 1); //strip " |
253 | boundary = boundary.right(boundary.length() - 1); //strip " | 251 | boundary = boundary.right(boundary.length() - 1); //strip " |
254 | } | 252 | } |
255 | boundary = "--" + boundary; //create boundary field | 253 | boundary = "--" + boundary; //create boundary field |
256 | } | 254 | } |
257 | 255 | ||
258 | if (boundary == "") { //fooled by Mime-Version | 256 | if (boundary == "") { //fooled by Mime-Version |
259 | mail->body = body; | 257 | mail->body = body; |
260 | mail->bodyPlain = body; | 258 | mail->bodyPlain = body; |
261 | return mail; | 259 | return mail; |
262 | } | 260 | } |
263 | 261 | ||
diff --git a/noncore/net/mailit/mailitwindow.cpp b/noncore/net/mailit/mailitwindow.cpp index fd49c1f..2bf1dcb 100644 --- a/noncore/net/mailit/mailitwindow.cpp +++ b/noncore/net/mailit/mailitwindow.cpp | |||
@@ -1,136 +1,133 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "mailitwindow.h" | 20 | #include "mailitwindow.h" |
21 | 21 | ||
22 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) | 22 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) |
23 | : QMainWindow(parent, name, fl) | 23 | : QMainWindow(parent, name, fl) |
24 | { | 24 | { |
25 | currentCaption = "Mailit"; | 25 | currentCaption = "Mailit"; |
26 | setCaption(tr(currentCaption)); | 26 | setCaption(tr(currentCaption)); |
27 | views = new QWidgetStack(this); | 27 | views = new QWidgetStack(this); |
28 | setCentralWidget(views); | 28 | setCentralWidget(views); |
29 | 29 | ||
30 | qWarning("***Starting writeMail"); | ||
31 | emailClient = new EmailClient(views, "client"); | 30 | emailClient = new EmailClient(views, "client"); |
32 | writeMail = new WriteMail(views, "writing"); | 31 | writeMail = new WriteMail(views, "writing"); |
33 | readMail = new ReadMail(views, "reading"); | 32 | readMail = new ReadMail(views, "reading"); |
34 | qWarning("***Finished readMail"); | ||
35 | 33 | ||
36 | views->raiseWidget(emailClient); | 34 | views->raiseWidget(emailClient); |
37 | 35 | ||
38 | connect(emailClient, SIGNAL(composeRequested()), | 36 | connect(emailClient, SIGNAL(composeRequested()), |
39 | this, SLOT(compose()) ); | 37 | this, SLOT(compose()) ); |
40 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, | 38 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, |
41 | SLOT(viewMail(QListView *, Email *)) ); | 39 | SLOT(viewMail(QListView *, Email *)) ); |
42 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, | 40 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, |
43 | SLOT(updateMailView(Email *)) ); | 41 | SLOT(updateMailView(Email *)) ); |
44 | 42 | ||
45 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); | 43 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); |
46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, | 44 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, |
47 | SLOT(showEmailClient()) ); | 45 | SLOT(showEmailClient()) ); |
48 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, | 46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, |
49 | SLOT(enqueMail(const Email &)) ); | 47 | SLOT(enqueMail(const Email &)) ); |
50 | 48 | ||
51 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); | 49 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); |
52 | connect(readMail, SIGNAL(replyRequested(Email &)), this, | 50 | connect(readMail, SIGNAL(replyRequested(Email &)), this, |
53 | SLOT(composeReply(Email &)) ); | 51 | SLOT(composeReply(Email &)) ); |
54 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, | 52 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, |
55 | SLOT(deleteMail(EmailListItem *, bool &)) ); | 53 | SLOT(deleteMail(EmailListItem *, bool &)) ); |
56 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, | 54 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, |
57 | SLOT(moveMailFront(Email *)) ); | 55 | SLOT(moveMailFront(Email *)) ); |
58 | 56 | ||
59 | connect(emailClient, SIGNAL(newCaption(const QString &)), | 57 | connect(emailClient, SIGNAL(newCaption(const QString &)), |
60 | this, SLOT(updateCaption(const QString &)) ); | 58 | this, SLOT(updateCaption(const QString &)) ); |
61 | viewingMail = FALSE; | 59 | viewingMail = FALSE; |
62 | 60 | ||
63 | qWarning("***Finished MailitWindow"); | ||
64 | } | 61 | } |
65 | 62 | ||
66 | MailItWindow::~MailItWindow() | 63 | MailItWindow::~MailItWindow() |
67 | { | 64 | { |
68 | } | 65 | } |
69 | 66 | ||
70 | void MailItWindow::closeEvent(QCloseEvent *e) | 67 | void MailItWindow::closeEvent(QCloseEvent *e) |
71 | { | 68 | { |
72 | if (views->visibleWidget() == emailClient) { | 69 | if (views->visibleWidget() == emailClient) { |
73 | e->accept(); | 70 | e->accept(); |
74 | } else { | 71 | } else { |
75 | showEmailClient(); | 72 | showEmailClient(); |
76 | } | 73 | } |
77 | } | 74 | } |
78 | 75 | ||
79 | void MailItWindow::compose() | 76 | void MailItWindow::compose() |
80 | { | 77 | { |
81 | viewingMail = FALSE; | 78 | viewingMail = FALSE; |
82 | emailClient->hide(); | 79 | emailClient->hide(); |
83 | readMail->hide(); | 80 | readMail->hide(); |
84 | views->raiseWidget(writeMail); | 81 | views->raiseWidget(writeMail); |
85 | writeMail->setAddressList(emailClient->getAdrListRef()); | 82 | writeMail->setAddressList(emailClient->getAdrListRef()); |
86 | setCaption( tr( "Write mail" ) ); | 83 | setCaption( tr( "Write mail" ) ); |
87 | } | 84 | } |
88 | 85 | ||
89 | void MailItWindow::composeReply(Email &mail) | 86 | void MailItWindow::composeReply(Email &mail) |
90 | { | 87 | { |
91 | compose(); | 88 | compose(); |
92 | writeMail->reply(mail); | 89 | writeMail->reply(mail); |
93 | } | 90 | } |
94 | 91 | ||
95 | void MailItWindow::showEmailClient() | 92 | void MailItWindow::showEmailClient() |
96 | { | 93 | { |
97 | viewingMail = FALSE; | 94 | viewingMail = FALSE; |
98 | writeMail->hide(); | 95 | writeMail->hide(); |
99 | readMail->hide(); | 96 | readMail->hide(); |
100 | views->raiseWidget(emailClient); | 97 | views->raiseWidget(emailClient); |
101 | setCaption( tr(currentCaption) ); | 98 | setCaption( tr(currentCaption) ); |
102 | } | 99 | } |
103 | 100 | ||
104 | void MailItWindow::viewMail(QListView *view, Email *mail) | 101 | void MailItWindow::viewMail(QListView *view, Email *mail) |
105 | { | 102 | { |
106 | viewingMail = TRUE; | 103 | viewingMail = TRUE; |
107 | emailClient->hide(); | 104 | emailClient->hide(); |
108 | readMail->update(view, mail); | 105 | readMail->update(view, mail); |
109 | views->raiseWidget(readMail); | 106 | views->raiseWidget(readMail); |
110 | setCaption( tr( "Examine mail" ) ); | 107 | setCaption( tr( "Examine mail" ) ); |
111 | } | 108 | } |
112 | 109 | ||
113 | void MailItWindow::updateMailView(Email *mail) | 110 | void MailItWindow::updateMailView(Email *mail) |
114 | { | 111 | { |
115 | if (viewingMail) { | 112 | if (viewingMail) { |
116 | readMail->mailUpdated(mail); | 113 | readMail->mailUpdated(mail); |
117 | } | 114 | } |
118 | } | 115 | } |
119 | 116 | ||
120 | void MailItWindow::updateCaption(const QString &newCaption) | 117 | void MailItWindow::updateCaption(const QString &newCaption) |
121 | { | 118 | { |
122 | currentCaption = newCaption; | 119 | currentCaption = newCaption; |
123 | setCaption(tr(currentCaption)); | 120 | setCaption(tr(currentCaption)); |
124 | } | 121 | } |
125 | 122 | ||
126 | void MailItWindow::setDocument(const QString &_address) | 123 | void MailItWindow::setDocument(const QString &_address) |
127 | { | 124 | { |
128 | // strip leading 'mailto:' | 125 | // strip leading 'mailto:' |
129 | QString address = _address; | 126 | QString address = _address; |
130 | if (address.startsWith("mailto:")) | 127 | if (address.startsWith("mailto:")) |
131 | address = address.mid(6); | 128 | address = address.mid(6); |
132 | 129 | ||
133 | compose(); | 130 | compose(); |
134 | writeMail->setRecipient(address); | 131 | writeMail->setRecipient(address); |
135 | } | 132 | } |
136 | 133 | ||
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp index 2f14ed2..f9cc337 100644 --- a/noncore/net/mailit/popclient.cpp +++ b/noncore/net/mailit/popclient.cpp | |||
@@ -26,350 +26,350 @@ extern "C" { | |||
26 | } | 26 | } |
27 | 27 | ||
28 | #include <qcstring.h> | 28 | #include <qcstring.h> |
29 | 29 | ||
30 | PopClient::PopClient() | 30 | PopClient::PopClient() |
31 | { | 31 | { |
32 | socket = new QSocket(this, "popClient"); | 32 | socket = new QSocket(this, "popClient"); |
33 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); | 33 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); |
34 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); | 34 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); |
35 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); | 35 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); |
36 | 36 | ||
37 | stream = new QTextStream(socket); | 37 | stream = new QTextStream(socket); |
38 | 38 | ||
39 | receiving = FALSE; | 39 | receiving = FALSE; |
40 | synchronize = FALSE; | 40 | synchronize = FALSE; |
41 | lastSync = 0; | 41 | lastSync = 0; |
42 | headerLimit = 0; | 42 | headerLimit = 0; |
43 | preview = FALSE; | 43 | preview = FALSE; |
44 | } | 44 | } |
45 | 45 | ||
46 | PopClient::~PopClient() | 46 | PopClient::~PopClient() |
47 | { | 47 | { |
48 | delete socket; | 48 | delete socket; |
49 | delete stream; | 49 | delete stream; |
50 | } | 50 | } |
51 | 51 | ||
52 | void PopClient::newConnection(QString target, int port) | 52 | void PopClient::newConnection(QString target, int port) |
53 | { | 53 | { |
54 | if (receiving) { | 54 | if (receiving) { |
55 | qWarning("socket in use, connection refused"); | 55 | qWarning("socket in use, connection refused"); |
56 | return; | 56 | return; |
57 | } | 57 | } |
58 | 58 | ||
59 | status = Init; | 59 | status = Init; |
60 | 60 | ||
61 | socket->connectToHost(target, port); | 61 | socket->connectToHost(target, port); |
62 | receiving = TRUE; | 62 | receiving = TRUE; |
63 | selected = FALSE; | 63 | selected = FALSE; |
64 | 64 | ||
65 | emit updateStatus("DNS lookup"); | 65 | emit updateStatus("DNS lookup"); |
66 | } | 66 | } |
67 | 67 | ||
68 | void PopClient::setAccount(QString popUser, QString popPasswd) | 68 | void PopClient::setAccount(QString popUser, QString popPasswd) |
69 | { | 69 | { |
70 | popUserName = popUser; | 70 | popUserName = popUser; |
71 | popPassword = popPasswd; | 71 | popPassword = popPasswd; |
72 | } | 72 | } |
73 | 73 | ||
74 | void PopClient::setSynchronize(int lastCount) | 74 | void PopClient::setSynchronize(int lastCount) |
75 | { | 75 | { |
76 | synchronize = TRUE; | 76 | synchronize = TRUE; |
77 | lastSync = lastCount; | 77 | lastSync = lastCount; |
78 | } | 78 | } |
79 | 79 | ||
80 | void PopClient::removeSynchronize() | 80 | void PopClient::removeSynchronize() |
81 | { | 81 | { |
82 | synchronize = FALSE; | 82 | synchronize = FALSE; |
83 | lastSync = 0; | 83 | lastSync = 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | void PopClient::headersOnly(bool headers, int limit) | 86 | void PopClient::headersOnly(bool headers, int limit) |
87 | { | 87 | { |
88 | preview = headers; | 88 | preview = headers; |
89 | headerLimit = limit; | 89 | headerLimit = limit; |
90 | } | 90 | } |
91 | 91 | ||
92 | void PopClient::setSelectedMails(MailList *list) | 92 | void PopClient::setSelectedMails(MailList *list) |
93 | { | 93 | { |
94 | selected = TRUE; | 94 | selected = TRUE; |
95 | mailList = list; | 95 | mailList = list; |
96 | } | 96 | } |
97 | 97 | ||
98 | void PopClient::connectionEstablished() | 98 | void PopClient::connectionEstablished() |
99 | { | 99 | { |
100 | emit updateStatus(tr("Connection established")); | 100 | emit updateStatus(tr("Connection established")); |
101 | } | 101 | } |
102 | 102 | ||
103 | void PopClient::errorHandling(int status) | 103 | void PopClient::errorHandling(int status) |
104 | { | 104 | { |
105 | emit updateStatus(tr("Error Occured")); | 105 | emit updateStatus(tr("Error Occured")); |
106 | emit errorOccurred(status); | 106 | emit errorOccurred(status); |
107 | socket->close(); | 107 | socket->close(); |
108 | receiving = FALSE; | 108 | receiving = FALSE; |
109 | } | 109 | } |
110 | 110 | ||
111 | void PopClient::incomingData() | 111 | void PopClient::incomingData() |
112 | { | 112 | { |
113 | QString response, temp, temp2, timeStamp; | 113 | QString response, temp, temp2, timeStamp; |
114 | QString md5Source; | 114 | QString md5Source; |
115 | int start, end; | 115 | int start, end; |
116 | // char *md5Digest; | 116 | // char *md5Digest; |
117 | char md5Digest[16]; | 117 | char md5Digest[16]; |
118 | // if ( !socket->canReadLine() ) | 118 | // if ( !socket->canReadLine() ) |
119 | // return; | 119 | // return; |
120 | 120 | ||
121 | response = socket->readLine(); | 121 | response = socket->readLine(); |
122 | qDebug(response +" %d", status); | 122 | //qDebug(response +" %d", status); |
123 | 123 | ||
124 | switch(status) { | 124 | switch(status) { |
125 | //logging in | 125 | //logging in |
126 | case Init: { | 126 | case Init: { |
127 | #ifdef APOP_TEST | 127 | #ifdef APOP_TEST |
128 | start = response.find('<',0); | 128 | start = response.find('<',0); |
129 | end = response.find('>', start); | 129 | end = response.find('>', start); |
130 | if( start >= 0 && end > start ) | 130 | if( start >= 0 && end > start ) |
131 | { | 131 | { |
132 | timeStamp = response.mid( start , end - start + 1); | 132 | timeStamp = response.mid( start , end - start + 1); |
133 | md5Source = timeStamp + popPassword; | 133 | md5Source = timeStamp + popPassword; |
134 | qDebug( md5Source); | 134 | //qDebug( md5Source); |
135 | // for( int i = 0; i < md5Source.length(); i++) { | 135 | // for( int i = 0; i < md5Source.length(); i++) { |
136 | // buff[i] = (QChar)md5Source[i]; | 136 | // buff[i] = (QChar)md5Source[i]; |
137 | // } | 137 | // } |
138 | 138 | ||
139 | md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); | 139 | md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); |
140 | // md5_buffer(char const *buffer, unsigned int len, char *digest); | 140 | // md5_buffer(char const *buffer, unsigned int len, char *digest); |
141 | 141 | ||
142 | // MD5_Init( &ctx); | 142 | // MD5_Init( &ctx); |
143 | // MD5_Update( &ctx, buff, sizeof( buff) ); | 143 | // MD5_Update( &ctx, buff, sizeof( buff) ); |
144 | // MD5_Final( md5Digest, &ctx); | 144 | // MD5_Final( md5Digest, &ctx); |
145 | // MD5( buff, md5Source.length(), md5Digest); | 145 | // MD5( buff, md5Source.length(), md5Digest); |
146 | 146 | ||
147 | for(int j =0;j < MD5_DIGEST_LENGTH ;j++) | 147 | for(int j =0;j < MD5_DIGEST_LENGTH ;j++) |
148 | { | 148 | { |
149 | printf("%x", md5Digest[j]); | 149 | printf("%x", md5Digest[j]); |
150 | } | 150 | } |
151 | printf("\n"); | 151 | printf("\n"); |
152 | // qDebug(md5Digest); | 152 | // qDebug(md5Digest); |
153 | *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; | 153 | *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; |
154 | // qDebug("%s", stream); | 154 | // qDebug("%s", stream); |
155 | status = Stat; | 155 | status = Stat; |
156 | } | 156 | } |
157 | else | 157 | else |
158 | #endif | 158 | #endif |
159 | { | 159 | { |
160 | timeStamp = ""; | 160 | timeStamp = ""; |
161 | *stream << "USER " << popUserName << "\r\n"; | 161 | *stream << "USER " << popUserName << "\r\n"; |
162 | status = Pass; | 162 | status = Pass; |
163 | } | 163 | } |
164 | 164 | ||
165 | break; | 165 | break; |
166 | } | 166 | } |
167 | //password shhh. don't tell anyone (implement APOP...) | 167 | //password shhh. don't tell anyone (implement APOP...) |
168 | case Pass: { | 168 | case Pass: { |
169 | *stream << "PASS " << popPassword << "\r\n"; | 169 | *stream << "PASS " << popPassword << "\r\n"; |
170 | status = Stat; | 170 | status = Stat; |
171 | break; | 171 | break; |
172 | } | 172 | } |
173 | //ask for number of messages | 173 | //ask for number of messages |
174 | case Stat: { | 174 | case Stat: { |
175 | if (response[0] == '+') { | 175 | if (response[0] == '+') { |
176 | *stream << "STAT" << "\r\n"; | 176 | *stream << "STAT" << "\r\n"; |
177 | status = Mcnt; | 177 | status = Mcnt; |
178 | } else errorHandling(ErrLoginFailed); | 178 | } else errorHandling(ErrLoginFailed); |
179 | break; | 179 | break; |
180 | } | 180 | } |
181 | //get count of messages, eg "+OK 4 900.." -> int 4 | 181 | //get count of messages, eg "+OK 4 900.." -> int 4 |
182 | case Mcnt: { | 182 | case Mcnt: { |
183 | if (response[0] == '+') { | 183 | if (response[0] == '+') { |
184 | temp = response.replace(0, 4, ""); | 184 | temp = response.replace(0, 4, ""); |
185 | int x = temp.find(" ", 0); | 185 | int x = temp.find(" ", 0); |
186 | temp.truncate((uint) x); | 186 | temp.truncate((uint) x); |
187 | newMessages = temp.toInt(); | 187 | newMessages = temp.toInt(); |
188 | messageCount = 1; | 188 | messageCount = 1; |
189 | status = List; | 189 | status = List; |
190 | 190 | ||
191 | if (synchronize) { | 191 | if (synchronize) { |
192 | //messages deleted from server, reload all | 192 | //messages deleted from server, reload all |
193 | if (newMessages < lastSync) | 193 | if (newMessages < lastSync) |
194 | lastSync = 0; | 194 | lastSync = 0; |
195 | messageCount = lastSync + 1; | 195 | messageCount = 1; |
196 | } | 196 | } |
197 | 197 | ||
198 | if (selected) { | 198 | if (selected) { |
199 | int *ptr = mailList->first(); | 199 | int *ptr = mailList->first(); |
200 | if (ptr != 0) { | 200 | if (ptr != 0) { |
201 | newMessages++; //to ensure no early jumpout | 201 | newMessages++; //to ensure no early jumpout |
202 | messageCount = *(mailList->first()); | 202 | messageCount = *(mailList->first()); |
203 | } else newMessages = 0; | 203 | } else newMessages = 0; |
204 | } | 204 | } |
205 | } else errorHandling(ErrUnknownResponse); | 205 | } else errorHandling(ErrUnknownResponse); |
206 | } | 206 | } |
207 | //Read message number x, count upwards to messageCount | 207 | //Read message number x, count upwards to messageCount |
208 | case List: { | 208 | case List: { |
209 | if (messageCount <= newMessages) { | 209 | if (messageCount <= newMessages) { |
210 | *stream << "LIST " << messageCount << "\r\n"; | 210 | *stream << "LIST " << messageCount << "\r\n"; |
211 | status = Size; | 211 | status = Size; |
212 | temp2.setNum(newMessages - lastSync); | 212 | temp2.setNum(newMessages - lastSync); |
213 | temp.setNum(messageCount - lastSync); | 213 | temp.setNum(messageCount - lastSync); |
214 | if (!selected) { | 214 | if (!selected) { |
215 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); | 215 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
216 | } else { | 216 | } else { |
217 | //completing a previously closed transfer | 217 | //completing a previously closed transfer |
218 | if ( (messageCount - lastSync) <= 0) { | 218 | if ( (messageCount - lastSync) <= 0) { |
219 | temp.setNum(messageCount); | 219 | temp.setNum(messageCount); |
220 | emit updateStatus(tr("Previous message ") + temp); | 220 | emit updateStatus(tr("Previous message ") + temp); |
221 | } else { | 221 | } else { |
222 | emit updateStatus(tr("Completing message ") + temp); | 222 | emit updateStatus(tr("Completing message ") + temp); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | break; | 225 | break; |
226 | } else { | 226 | } else { |
227 | emit updateStatus(tr("No new Messages")); | 227 | emit updateStatus(tr("No new Messages")); |
228 | status = Quit; | 228 | status = Quit; |
229 | } | 229 | } |
230 | } | 230 | } |
231 | //get size of message, eg "500 characters in message.." -> int 500 | 231 | //get size of message, eg "500 characters in message.." -> int 500 |
232 | case Size: { | 232 | case Size: { |
233 | if (status != Quit) { //because of idiotic switch | 233 | if (status != Quit) { //because of idiotic switch |
234 | if (response[0] == '+') { | 234 | if (response[0] == '+') { |
235 | temp = response.replace(0, 4, ""); | 235 | temp = response.replace(0, 4, ""); |
236 | int x = temp.find(" ", 0); | 236 | int x = temp.find(" ", 0); |
237 | temp = temp.right(temp.length() - ((uint) x + 1) ); | 237 | temp = temp.right(temp.length() - ((uint) x + 1) ); |
238 | mailSize = temp.toInt(); | 238 | mailSize = temp.toInt(); |
239 | emit currentMailSize(mailSize); | 239 | emit currentMailSize(mailSize); |
240 | 240 | ||
241 | status = Retr; | 241 | status = Retr; |
242 | } else { | 242 | } else { |
243 | qWarning(response); | 243 | //qWarning(response); |
244 | errorHandling(ErrUnknownResponse); | 244 | errorHandling(ErrUnknownResponse); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
248 | //Read message number x, count upwards to messageCount | 248 | //Read message number x, count upwards to messageCount |
249 | case Retr: { | 249 | case Retr: { |
250 | if (status != Quit) { | 250 | if (status != Quit) { |
251 | if (!preview || mailSize <= headerLimit) { | 251 | if (!preview || mailSize <= headerLimit) { |
252 | *stream << "RETR " << messageCount << "\r\n"; | 252 | *stream << "RETR " << messageCount << "\r\n"; |
253 | } else { //only header | 253 | } else { //only header |
254 | *stream << "TOP " << messageCount << " 0\r\n"; | 254 | *stream << "TOP " << messageCount << " 0\r\n"; |
255 | } | 255 | } |
256 | messageCount++; | 256 | messageCount++; |
257 | status = Ignore; | 257 | status = Ignore; |
258 | break; | 258 | break; |
259 | } } | 259 | } } |
260 | case Ignore: { | 260 | case Ignore: { |
261 | if (status != Quit) { //because of idiotic switch | 261 | if (status != Quit) { //because of idiotic switch |
262 | if (response[0] == '+') { | 262 | if (response[0] == '+') { |
263 | message = ""; | 263 | message = ""; |
264 | status = Read; | 264 | status = Read; |
265 | if (!socket->canReadLine()) //sync. problems | 265 | if (!socket->canReadLine()) //sync. problems |
266 | break; | 266 | break; |
267 | response = socket->readLine(); | 267 | response = socket->readLine(); |
268 | } else errorHandling(ErrUnknownResponse); | 268 | } else errorHandling(ErrUnknownResponse); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | //add all incoming lines to body. When size is reached, send | 271 | //add all incoming lines to body. When size is reached, send |
272 | //message, and go back to read new message | 272 | //message, and go back to read new message |
273 | case Read: { | 273 | case Read: { |
274 | if (status != Quit) { //because of idiotic switch | 274 | if (status != Quit) { //because of idiotic switch |
275 | message += response; | 275 | message += response; |
276 | while ( socket->canReadLine() ) { | 276 | while ( socket->canReadLine() ) { |
277 | response = socket->readLine(); | 277 | response = socket->readLine(); |
278 | message += response; | 278 | message += response; |
279 | } | 279 | } |
280 | emit downloadedSize(message.length()); | 280 | emit downloadedSize(message.length()); |
281 | int x = message.find("\r\n.\r\n",-5); | 281 | int x = message.find("\r\n.\r\n",-5); |
282 | if (x == -1) { | 282 | if (x == -1) { |
283 | break; | 283 | break; |
284 | } else { //message reach entire size | 284 | } else { //message reach entire size |
285 | //complete mail downloaded | 285 | //complete mail downloaded |
286 | if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ | 286 | if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ |
287 | emit newMessage(message, messageCount-1, mailSize, TRUE); | 287 | emit newMessage(message, messageCount-1, mailSize, TRUE); |
288 | } else { //incomplete mail downloaded | 288 | } else { //incomplete mail downloaded |
289 | emit newMessage(message, messageCount-1, mailSize, FALSE); | 289 | emit newMessage(message, messageCount-1, mailSize, FALSE); |
290 | } | 290 | } |
291 | if (messageCount > newMessages) //that was the last message | 291 | if (messageCount > newMessages) //that was the last message |
292 | status = Quit; | 292 | status = Quit; |
293 | else { //ask for new message | 293 | else { //ask for new message |
294 | if (selected) { //grab next from queue | 294 | if (selected) { //grab next from queue |
295 | int *ptr = mailList->next(); | 295 | int *ptr = mailList->next(); |
296 | if (ptr != 0) { | 296 | if (ptr != 0) { |
297 | messageCount = *ptr; | 297 | messageCount = *ptr; |
298 | *stream << "LIST " << messageCount << "\r\n"; | 298 | *stream << "LIST " << messageCount << "\r\n"; |
299 | status = Size; | 299 | status = Size; |
300 | //completing a previously closed transfer | 300 | //completing a previously closed transfer |
301 | if ( (messageCount - lastSync) <= 0) { | 301 | if ( (messageCount - lastSync) <= 0) { |
302 | temp.setNum(messageCount); | 302 | temp.setNum(messageCount); |
303 | emit updateStatus(tr("Previous message ") + temp); | 303 | emit updateStatus(tr("Previous message ") + temp); |
304 | } else { | 304 | } else { |
305 | temp.setNum(messageCount - lastSync); | 305 | temp.setNum(messageCount - lastSync); |
306 | emit updateStatus(tr("Completing message ") + temp); | 306 | emit updateStatus(tr("Completing message ") + temp); |
307 | } | 307 | } |
308 | break; | 308 | break; |
309 | } else { | 309 | } else { |
310 | newMessages--; | 310 | newMessages--; |
311 | status = Quit; | 311 | status = Quit; |
312 | } | 312 | } |
313 | } else { | 313 | } else { |
314 | *stream << "LIST " << messageCount << "\r\n"; | 314 | *stream << "LIST " << messageCount << "\r\n"; |
315 | status = Size; | 315 | status = Size; |
316 | temp2.setNum(newMessages - lastSync); | 316 | temp2.setNum(newMessages - lastSync); |
317 | temp.setNum(messageCount - lastSync); | 317 | temp.setNum(messageCount - lastSync); |
318 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); | 318 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
319 | 319 | ||
320 | break; | 320 | break; |
321 | } | 321 | } |
322 | } | 322 | } |
323 | } | 323 | } |
324 | if (status != Quit) | 324 | if (status != Quit) |
325 | break; | 325 | break; |
326 | } | 326 | } |
327 | } | 327 | } |
328 | case Quit: { | 328 | case Quit: { |
329 | *stream << "Quit\r\n"; | 329 | *stream << "Quit\r\n"; |
330 | status = Done; | 330 | status = Done; |
331 | int newM = newMessages - lastSync; | 331 | int newM = newMessages - lastSync; |
332 | if (newM > 0) { | 332 | if (newM > 0) { |
333 | temp.setNum(newM); | 333 | temp.setNum(newM); |
334 | emit updateStatus(temp + tr(" new messages")); | 334 | emit updateStatus(temp + tr(" new messages")); |
335 | } else { | 335 | } else { |
336 | emit updateStatus(tr("No new messages")); | 336 | emit updateStatus(tr("No new messages")); |
337 | } | 337 | } |
338 | 338 | ||
339 | socket->close(); | 339 | socket->close(); |
340 | receiving = FALSE; | 340 | receiving = FALSE; |
341 | emit mailTransfered(newM); | 341 | emit mailTransfered(newM); |
342 | break; | 342 | break; |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | } | 346 | } |
347 | 347 | ||
348 | // if( bAPOPAuthentication ) | 348 | // if( bAPOPAuthentication ) |
349 | // { | 349 | // { |
350 | // if( m_strTimeStamp.IsEmpty() ) | 350 | // if( m_strTimeStamp.IsEmpty() ) |
351 | // { | 351 | // { |
352 | // SetLastError("Apop error!"); | 352 | // SetLastError("Apop error!"); |
353 | // return false; | 353 | // return false; |
354 | // } | 354 | // } |
355 | // strMD5Source = m_strTimeStamp+pszPassword; | 355 | // strMD5Source = m_strTimeStamp+pszPassword; |
356 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); | 356 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); |
357 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); | 357 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); |
358 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); | 358 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); |
359 | // if(ret == SOCKET_ERROR) | 359 | // if(ret == SOCKET_ERROR) |
360 | // { | 360 | // { |
361 | // SetLastError("Socket error!"); | 361 | // SetLastError("Socket error!"); |
362 | // m_bSocketOK = false; | 362 | // m_bSocketOK = false; |
363 | // m_bConnected = false; | 363 | // m_bConnected = false; |
364 | // return false; | 364 | // return false; |
365 | // } | 365 | // } |
366 | // if( !GetSocketResult(&strResult , COMMAND_END_FLAG) ) | 366 | // if( !GetSocketResult(&strResult , COMMAND_END_FLAG) ) |
367 | // return false; | 367 | // return false; |
368 | // if( 0 == strResult.Find('-' , 0) ) | 368 | // if( 0 == strResult.Find('-' , 0) ) |
369 | // { | 369 | // { |
370 | // SetLastError("Username or Password error!"); | 370 | // SetLastError("Username or Password error!"); |
371 | // return false; | 371 | // return false; |
372 | // } | 372 | // } |
373 | // m_bConnected = true; | 373 | // m_bConnected = true; |
374 | 374 | ||
375 | // } | 375 | // } |
diff --git a/noncore/net/mailit/readmail.cpp b/noncore/net/mailit/readmail.cpp index a5e7147..7cd3e09 100644 --- a/noncore/net/mailit/readmail.cpp +++ b/noncore/net/mailit/readmail.cpp | |||
@@ -1,187 +1,188 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "readmail.h" | 20 | #include "readmail.h" |
21 | #include <qimage.h> | 21 | #include <qimage.h> |
22 | #include <qmime.h> | 22 | #include <qmime.h> |
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) | 26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) |
27 | : QMainWindow(parent, name, fl) | 27 | : QMainWindow(parent, name, fl) |
28 | { | 28 | { |
29 | plainTxt = FALSE; | 29 | plainTxt = FALSE; |
30 | 30 | ||
31 | init(); | 31 | init(); |
32 | viewAtt = new ViewAtt(0, "View Attatchments"); | 32 | viewAtt = new ViewAtt(0, "View Attatchments"); |
33 | } | 33 | } |
34 | 34 | ||
35 | ReadMail::~ReadMail() | 35 | ReadMail::~ReadMail() |
36 | { | 36 | { |
37 | delete emailView->mimeSourceFactory(); | 37 | delete emailView->mimeSourceFactory(); |
38 | delete viewAtt; | 38 | delete viewAtt; |
39 | } | 39 | } |
40 | 40 | ||
41 | void ReadMail::init() | 41 | void ReadMail::init() |
42 | { | 42 | { |
43 | setToolBarsMovable(FALSE); | 43 | setToolBarsMovable(FALSE); |
44 | 44 | ||
45 | bar = new QToolBar(this); | 45 | bar = new QToolBar(this); |
46 | bar->setHorizontalStretchable( TRUE ); | 46 | bar->setHorizontalStretchable( TRUE ); |
47 | 47 | ||
48 | menu = new QMenuBar( bar ); | 48 | menu = new QMenuBar( bar ); |
49 | 49 | ||
50 | viewMenu = new QPopupMenu(menu); | 50 | viewMenu = new QPopupMenu(menu); |
51 | menu->insertItem( tr( "&View" ), viewMenu); | 51 | menu->insertItem( tr( "&View" ), viewMenu); |
52 | 52 | ||
53 | mailMenu = new QPopupMenu(menu); | 53 | mailMenu = new QPopupMenu(menu); |
54 | menu->insertItem( tr( "&Mail" ), mailMenu); | 54 | menu->insertItem( tr( "&Mail" ), mailMenu); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | 57 | ||
58 | //reply dependant on viewing inbox | 58 | //reply dependant on viewing inbox |
59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), | 59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), |
60 | QString::null, 0, this, 0 ); | 60 | QString::null, 0, this, 0 ); |
61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); | 61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); |
62 | 62 | ||
63 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 63 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
64 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); | 64 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); |
65 | previousButton->addTo(bar); | 65 | previousButton->addTo(bar); |
66 | previousButton->addTo(viewMenu); | 66 | previousButton->addTo(viewMenu); |
67 | 67 | ||
68 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); | 68 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); |
69 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); | 69 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); |
70 | nextButton->addTo(bar); | 70 | nextButton->addTo(bar); |
71 | nextButton->addTo(viewMenu); | 71 | nextButton->addTo(viewMenu); |
72 | 72 | ||
73 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); | 73 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); |
74 | connect( attatchmentsButton, SIGNAL( activated() ), this, | 74 | connect( attatchmentsButton, SIGNAL( activated() ), this, |
75 | SLOT( viewAttatchments() ) ); | 75 | SLOT( viewAttatchments() ) ); |
76 | attatchmentsButton->addTo(bar); | 76 | attatchmentsButton->addTo(bar); |
77 | attatchmentsButton->addTo(viewMenu); | 77 | attatchmentsButton->addTo(viewMenu); |
78 | 78 | ||
79 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); | 79 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); |
80 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); | 80 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); |
81 | plainTextButton->addTo(bar); | 81 | plainTextButton->addTo(bar); |
82 | plainTextButton->addTo(viewMenu); | 82 | plainTextButton->addTo(viewMenu); |
83 | 83 | ||
84 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 84 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
85 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 85 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
86 | deleteButton->addTo(bar); | 86 | deleteButton->addTo(bar); |
87 | deleteButton->addTo(mailMenu); | 87 | deleteButton->addTo(mailMenu); |
88 | 88 | ||
89 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); | 89 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); |
90 | 90 | ||
91 | emailView = new QTextView( this, "emailView" ); | 91 | emailView = new QTextView( this, "emailView" ); |
92 | |||
92 | setCentralWidget(emailView); | 93 | setCentralWidget(emailView); |
93 | 94 | ||
94 | mime = new QMimeSourceFactory(); | 95 | mime = new QMimeSourceFactory(); |
95 | emailView->setMimeSourceFactory(mime); | 96 | emailView->setMimeSourceFactory(mime); |
96 | } | 97 | } |
97 | 98 | ||
98 | void ReadMail::updateView() | 99 | void ReadMail::updateView() |
99 | { | 100 | { |
100 | Enclosure *ePtr; | 101 | Enclosure *ePtr; |
101 | QString mailStringSize; | 102 | QString mailStringSize; |
102 | QString text, temp; | 103 | QString text, temp; |
103 | 104 | ||
104 | mail->read = TRUE; //mark as read | 105 | mail->read = TRUE; //mark as read |
105 | inbox = mail->received; | 106 | inbox = mail->received; |
106 | 107 | ||
107 | replyButton->removeFrom(mailMenu); | 108 | replyButton->removeFrom(mailMenu); |
108 | replyButton->removeFrom(bar); | 109 | replyButton->removeFrom(bar); |
109 | 110 | ||
110 | if (inbox == TRUE) { | 111 | if (inbox == TRUE) { |
111 | replyButton->addTo(bar); | 112 | replyButton->addTo(bar); |
112 | replyButton->addTo(mailMenu); | 113 | replyButton->addTo(mailMenu); |
113 | 114 | ||
114 | if (!mail->downloaded) { | 115 | if (!mail->downloaded) { |
115 | //report currently viewed mail so that it will be | 116 | //report currently viewed mail so that it will be |
116 | //placed first in the queue of new mails to download | 117 | //placed first in the queue of new mails to download |
117 | emit viewingMail(mail); | 118 | emit viewingMail(mail); |
118 | 119 | ||
119 | double mailSize = (double) mail->size; | 120 | double mailSize = (double) mail->size; |
120 | if (mailSize < 1024) { | 121 | if (mailSize < 1024) { |
121 | mailStringSize.setNum(mailSize); | 122 | mailStringSize.setNum(mailSize); |
122 | mailStringSize += " Bytes"; | 123 | mailStringSize += " Bytes"; |
123 | } else if (mailSize < 1024*1024) { | 124 | } else if (mailSize < 1024*1024) { |
124 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); | 125 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); |
125 | mailStringSize += " Kb"; | 126 | mailStringSize += " Kb"; |
126 | } else { | 127 | } else { |
127 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); | 128 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); |
128 | mailStringSize += " Mb"; | 129 | mailStringSize += " Mb"; |
129 | } | 130 | } |
130 | } | 131 | } |
131 | } | 132 | } |
132 | 133 | ||
133 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); | 134 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); |
134 | 135 | ||
135 | if (! plainTxt) { //use RichText, inline pics etc. | 136 | if (! plainTxt) { //use RichText, inline pics etc. |
136 | emailView->setTextFormat(QTextView::RichText); | 137 | emailView->setTextFormat(QTextView::RichText); |
137 | text = "<b><big><center><font color=\"blue\">" + mail->subject | 138 | text = "<b><big><center><font color=\"blue\">" + mail->subject |
138 | +"</font></center></big></b><br>"; | 139 | +"</font></center></big></b><br>"; |
139 | text += "<b>From: </b>" + mail->from + " <i>" + | 140 | text += "<b>From: </b>" + mail->from + " <i>" + |
140 | mail->fromMail + "</i><br>"; | 141 | mail->fromMail + "</i><br>"; |
141 | 142 | ||
142 | text +="<b>To: </b>"; | 143 | text +="<b>To: </b>"; |
143 | for (QStringList::Iterator it = mail->recipients.begin(); | 144 | for (QStringList::Iterator it = mail->recipients.begin(); |
144 | it != mail->recipients.end(); ++it ) { | 145 | it != mail->recipients.end(); ++it ) { |
145 | text += *it + " "; | 146 | text += *it + " "; |
146 | } | 147 | } |
147 | text += "<br>" + mail->date; | 148 | text += "<br>" + mail->date; |
148 | 149 | ||
149 | if (mail->files.count() > 0) { | 150 | if (mail->files.count() > 0) { |
150 | text += "<br><b>Attatchments: </b>"; | 151 | text += "<br><b>Attatchments: </b>"; |
151 | 152 | ||
152 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 153 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
153 | text += ePtr->originalName + " "; | 154 | text += ePtr->originalName + " "; |
154 | } | 155 | } |
155 | text += "<hr><br>" + mail->body; | 156 | text += "<hr><br>" + mail->body; |
156 | 157 | ||
157 | if (inbox) { | 158 | if (inbox) { |
158 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 159 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
159 | 160 | ||
160 | text += "<br><hr><b>Attatchment: </b>" + | 161 | text += "<br><hr><b>Attatchment: </b>" + |
161 | ePtr->originalName + "<hr>"; | 162 | ePtr->originalName + "<hr>"; |
162 | 163 | ||
163 | if (ePtr->contentType == "TEXT") { | 164 | if (ePtr->contentType == "TEXT") { |
164 | QFile f(ePtr->path + ePtr->name); | 165 | QFile f(ePtr->path + ePtr->name); |
165 | 166 | ||
166 | if (f.open(IO_ReadOnly) ) { | 167 | if (f.open(IO_ReadOnly) ) { |
167 | QTextStream t(&f); | 168 | QTextStream t(&f); |
168 | temp = t.read(); | 169 | temp = t.read(); |
169 | text += temp + "<br>"; | 170 | text += temp + "<br>"; |
170 | f.close(); | 171 | f.close(); |
171 | } else { | 172 | } else { |
172 | text += "<b>Could not locate file</b><br>"; | 173 | text += "<b>Could not locate file</b><br>"; |
173 | } | 174 | } |
174 | 175 | ||
175 | } | 176 | } |
176 | if (ePtr->contentType == "IMAGE") { | 177 | if (ePtr->contentType == "IMAGE") { |
177 | // temp.setNum(emailView->width());//get display width | 178 | // temp.setNum(emailView->width());//get display width |
178 | // text += "<img width=" + temp +" src =""" + | 179 | // text += "<img width=" + temp +" src =""" + |
179 | // ePtr->originalName + """> </img>"; | 180 | // ePtr->originalName + """> </img>"; |
180 | text += "<img src =""" + | 181 | text += "<img src =""" + |
181 | ePtr->originalName + """> </img>"; | 182 | ePtr->originalName + """> </img>"; |
182 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); | 183 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); |
183 | } | 184 | } |
184 | } | 185 | } |
185 | } | 186 | } |
186 | } else { | 187 | } else { |
187 | if (mail->downloaded || !inbox) { | 188 | if (mail->downloaded || !inbox) { |
diff --git a/noncore/net/mailit/smtpclient.cpp b/noncore/net/mailit/smtpclient.cpp index 6699a90..b2e38e5 100644 --- a/noncore/net/mailit/smtpclient.cpp +++ b/noncore/net/mailit/smtpclient.cpp | |||
@@ -1,171 +1,171 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "smtpclient.h" | 20 | #include "smtpclient.h" |
21 | #include "emailhandler.h" | 21 | #include "emailhandler.h" |
22 | 22 | ||
23 | SmtpClient::SmtpClient() | 23 | SmtpClient::SmtpClient() |
24 | { | 24 | { |
25 | socket = new QSocket(this, "smtpClient"); | 25 | socket = new QSocket(this, "smtpClient"); |
26 | stream = new QTextStream(socket); | 26 | stream = new QTextStream(socket); |
27 | mailList.setAutoDelete(TRUE); | 27 | mailList.setAutoDelete(TRUE); |
28 | 28 | ||
29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); | 29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); |
30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); | 30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); |
31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); | 31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); |
32 | 32 | ||
33 | sending = FALSE; | 33 | sending = FALSE; |
34 | } | 34 | } |
35 | 35 | ||
36 | SmtpClient::~SmtpClient() | 36 | SmtpClient::~SmtpClient() |
37 | { | 37 | { |
38 | delete socket; | 38 | delete socket; |
39 | delete stream; | 39 | delete stream; |
40 | } | 40 | } |
41 | 41 | ||
42 | void SmtpClient::newConnection(QString target, int port) | 42 | void SmtpClient::newConnection(QString target, int port) |
43 | { | 43 | { |
44 | if (sending) { | 44 | if (sending) { |
45 | qWarning("socket in use, connection refused"); | 45 | qWarning("socket in use, connection refused"); |
46 | return; | 46 | return; |
47 | } | 47 | } |
48 | 48 | ||
49 | status = Init; | 49 | status = Init; |
50 | sending = TRUE; | 50 | sending = TRUE; |
51 | socket->connectToHost(target, port); | 51 | socket->connectToHost(target, port); |
52 | 52 | ||
53 | emit updateStatus(tr("DNS lookup")); | 53 | emit updateStatus(tr("DNS lookup")); |
54 | } | 54 | } |
55 | 55 | ||
56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) | 56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) |
57 | { | 57 | { |
58 | RawEmail *mail = new RawEmail; | 58 | RawEmail *mail = new RawEmail; |
59 | 59 | ||
60 | mail->from = from; | 60 | mail->from = from; |
61 | mail->subject = subject; | 61 | mail->subject = subject; |
62 | mail->to = to; | 62 | mail->to = to; |
63 | mail->body = body; | 63 | mail->body = body; |
64 | 64 | ||
65 | mailList.append(mail); | 65 | mailList.append(mail); |
66 | } | 66 | } |
67 | 67 | ||
68 | void SmtpClient::connectionEstablished() | 68 | void SmtpClient::connectionEstablished() |
69 | { | 69 | { |
70 | emit updateStatus(tr("Connection established")); | 70 | emit updateStatus(tr("Connection established")); |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | void SmtpClient::errorHandling(int status) | 74 | void SmtpClient::errorHandling(int status) |
75 | { | 75 | { |
76 | emit errorOccurred(status); | 76 | emit errorOccurred(status); |
77 | socket->close(); | 77 | socket->close(); |
78 | mailList.clear(); | 78 | mailList.clear(); |
79 | sending = FALSE; | 79 | sending = FALSE; |
80 | } | 80 | } |
81 | 81 | ||
82 | void SmtpClient::incomingData() | 82 | void SmtpClient::incomingData() |
83 | { | 83 | { |
84 | QString response; | 84 | QString response; |
85 | 85 | ||
86 | if (!socket->canReadLine()) | 86 | if (!socket->canReadLine()) |
87 | return; | 87 | return; |
88 | 88 | ||
89 | response = socket->readLine(); | 89 | response = socket->readLine(); |
90 | qDebug(response); | 90 | //qDebug(response); |
91 | 91 | ||
92 | switch(status) { | 92 | switch(status) { |
93 | case Init: { | 93 | case Init: { |
94 | if (response[0] == '2') { | 94 | if (response[0] == '2') { |
95 | status = From; | 95 | status = From; |
96 | mailPtr = mailList.first(); | 96 | mailPtr = mailList.first(); |
97 | *stream << "HELO there\r\n"; | 97 | *stream << "HELO there\r\n"; |
98 | qDebug("HELO"); | 98 | //qDebug("HELO"); |
99 | } else errorHandling(ErrUnknownResponse); | 99 | } else errorHandling(ErrUnknownResponse); |
100 | break; | 100 | break; |
101 | } | 101 | } |
102 | case From: { | 102 | case From: { |
103 | if (response[0] == '2') { | 103 | if (response[0] == '2') { |
104 | *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n"; | 104 | *stream << "MAIL FROM: " << mailPtr->from << "\r\n"; |
105 | status = Recv; | 105 | status = Recv; |
106 | qDebug("MAIL FROM: "+mailPtr->from); | 106 | //qDebug("MAIL FROM: "+mailPtr->from); |
107 | } else errorHandling(ErrUnknownResponse); | 107 | } else errorHandling(ErrUnknownResponse); |
108 | break; | 108 | break; |
109 | } | 109 | } |
110 | case Recv: { | 110 | case Recv: { |
111 | if (response[0] == '2') { | 111 | if (response[0] == '2') { |
112 | it = mailPtr->to.begin(); | 112 | it = mailPtr->to.begin(); |
113 | if (it == NULL) | 113 | if (it == NULL) |
114 | errorHandling(ErrUnknownResponse); | 114 | errorHandling(ErrUnknownResponse); |
115 | *stream << "RCPT TO: <" << *it << ">\r\n"; | 115 | *stream << "RCPT TO: " << *it << ">\r\n"; |
116 | qDebug("RCPT TO: "+ *it); | 116 | //qDebug("RCPT TO: "+ *it); |
117 | status = MRcv; | 117 | status = MRcv; |
118 | } else errorHandling(ErrUnknownResponse); | 118 | } else errorHandling(ErrUnknownResponse); |
119 | break; | 119 | break; |
120 | } | 120 | } |
121 | case MRcv: { | 121 | case MRcv: { |
122 | if (response[0] == '2') { | 122 | if (response[0] == '2') { |
123 | it++; | 123 | it++; |
124 | if ( it != mailPtr->to.end() ) { | 124 | if ( it != mailPtr->to.end() ) { |
125 | *stream << "RCPT TO: <" << *it << ">\r\n"; | 125 | *stream << "RCPT TO: <" << *it << ">\r\n"; |
126 | qDebug("RCPT TO: "+ *it); | 126 | //qDebug("RCPT TO: "+ *it); |
127 | break; | 127 | break; |
128 | } else { | 128 | } else { |
129 | status = Data; | 129 | status = Data; |
130 | } | 130 | } |
131 | } else errorHandling(ErrUnknownResponse); | 131 | } else errorHandling(ErrUnknownResponse); |
132 | } | 132 | } |
133 | case Data: { | 133 | case Data: { |
134 | if (response[0] == '2') { | 134 | if (response[0] == '2') { |
135 | *stream << "DATA\r\n"; | 135 | *stream << "DATA\r\n"; |
136 | status = Body; | 136 | status = Body; |
137 | qDebug("DATA"); | 137 | //qDebug("DATA"); |
138 | emit updateStatus(tr("Sending: ") + mailPtr->subject); | 138 | emit updateStatus(tr("Sending: ") + mailPtr->subject); |
139 | } else errorHandling(ErrUnknownResponse); | 139 | } else errorHandling(ErrUnknownResponse); |
140 | break; | 140 | break; |
141 | } | 141 | } |
142 | case Body: { | 142 | case Body: { |
143 | if (response[0] == '3') { | 143 | if (response[0] == '3') { |
144 | *stream << mailPtr->body << "\r\n.\r\n"; | 144 | *stream << mailPtr->body << "\r\n.\r\n"; |
145 | mailPtr = mailList.next(); | 145 | mailPtr = mailList.next(); |
146 | if (mailPtr != NULL) { | 146 | if (mailPtr != NULL) { |
147 | status = From; | 147 | status = From; |
148 | } else { | 148 | } else { |
149 | status = Quit; | 149 | status = Quit; |
150 | } | 150 | } |
151 | qDebug("BODY"); | 151 | //qDebug("BODY"); |
152 | } else errorHandling(ErrUnknownResponse); | 152 | } else errorHandling(ErrUnknownResponse); |
153 | break; | 153 | break; |
154 | } | 154 | } |
155 | case Quit: { | 155 | case Quit: { |
156 | if (response[0] == '2') { | 156 | if (response[0] == '2') { |
157 | *stream << "QUIT\r\n"; | 157 | *stream << "QUIT\r\n"; |
158 | status = Done; | 158 | status = Done; |
159 | QString temp; | 159 | QString temp; |
160 | temp.setNum(mailList.count()); | 160 | temp.setNum(mailList.count()); |
161 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); | 161 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); |
162 | emit mailSent(); | 162 | emit mailSent(); |
163 | mailList.clear(); | 163 | mailList.clear(); |
164 | sending = FALSE; | 164 | sending = FALSE; |
165 | socket->close(); | 165 | socket->close(); |
166 | qDebug("QUIT"); | 166 | //qDebug("QUIT"); |
167 | } else errorHandling(ErrUnknownResponse); | 167 | } else errorHandling(ErrUnknownResponse); |
168 | break; | 168 | break; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | } | 171 | } |
diff --git a/noncore/unsupported/mailit/addresslist.cpp b/noncore/unsupported/mailit/addresslist.cpp index 9fe558a..8d9ab91 100644 --- a/noncore/unsupported/mailit/addresslist.cpp +++ b/noncore/unsupported/mailit/addresslist.cpp | |||
@@ -34,128 +34,128 @@ AddressList::AddressList() | |||
34 | AddressList::~AddressList() | 34 | AddressList::~AddressList() |
35 | { | 35 | { |
36 | addresses.clear(); | 36 | addresses.clear(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void AddressList::addContact(QString email, QString name) | 39 | void AddressList::addContact(QString email, QString name) |
40 | { | 40 | { |
41 | //skip if not a valid email address, | 41 | //skip if not a valid email address, |
42 | if (email.find( '@') == -1) | 42 | if (email.find( '@') == -1) |
43 | return; | 43 | return; |
44 | 44 | ||
45 | if ( ! containsEmail(email) ) { | 45 | if ( ! containsEmail(email) ) { |
46 | Contact *in = new Contact; | 46 | Contact *in = new Contact; |
47 | in->email = email; | 47 | in->email = email; |
48 | in->name = name; | 48 | in->name = name; |
49 | addresses.append(in); | 49 | addresses.append(in); |
50 | dirty = TRUE; | 50 | dirty = TRUE; |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | bool AddressList::containsEmail(QString email) | 54 | bool AddressList::containsEmail(QString email) |
55 | { | 55 | { |
56 | return ( getEmailRef(email) != -1 ); | 56 | return ( getEmailRef(email) != -1 ); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool AddressList::containsName(QString name) | 59 | bool AddressList::containsName(QString name) |
60 | { | 60 | { |
61 | return ( getNameRef(name) != -1 ); | 61 | return ( getNameRef(name) != -1 ); |
62 | } | 62 | } |
63 | 63 | ||
64 | QString AddressList::getNameByEmail(QString email) | 64 | QString AddressList::getNameByEmail(QString email) |
65 | { | 65 | { |
66 | int pos = getEmailRef(email); | 66 | int pos = getEmailRef(email); |
67 | if (pos != -1) { | 67 | if (pos != -1) { |
68 | Contact *ptr = addresses.at(pos); | 68 | Contact *ptr = addresses.at(pos); |
69 | return ptr->name; | 69 | return ptr->name; |
70 | } | 70 | } |
71 | 71 | ||
72 | return NULL; | 72 | return NULL; |
73 | } | 73 | } |
74 | 74 | ||
75 | QString AddressList::getEmailByName(QString name) | 75 | QString AddressList::getEmailByName(QString name) |
76 | { | 76 | { |
77 | int pos = getNameRef(name); | 77 | int pos = getNameRef(name); |
78 | if (pos != -1) { | 78 | if (pos != -1) { |
79 | Contact *ptr = addresses.at(pos); | 79 | Contact *ptr = addresses.at(pos); |
80 | return ptr->email; | 80 | return ptr->email; |
81 | } | 81 | } |
82 | 82 | ||
83 | return NULL; | 83 | return NULL; |
84 | } | 84 | } |
85 | 85 | ||
86 | int AddressList::getEmailRef(QString email) | 86 | int AddressList::getEmailRef(QString email) |
87 | { | 87 | { |
88 | int pos = 0; | 88 | int pos = 0; |
89 | Contact *ptr; | 89 | Contact *ptr; |
90 | 90 | ||
91 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { | 91 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { |
92 | if (ptr->email == email) | 92 | if (ptr->email == email) |
93 | return pos; | 93 | return pos; |
94 | pos++; | 94 | pos++; |
95 | } | 95 | } |
96 | return -1; | 96 | return -1; |
97 | } | 97 | } |
98 | 98 | ||
99 | int AddressList::getNameRef(QString name) | 99 | int AddressList::getNameRef(QString name) |
100 | { | 100 | { |
101 | int pos = 0; | 101 | int pos = 0; |
102 | Contact *ptr; | 102 | Contact *ptr; |
103 | 103 | ||
104 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { | 104 | for (ptr = addresses.first(); ptr != 0; ptr = addresses.next() ) { |
105 | if (ptr->name == name) | 105 | if (ptr->name == name) |
106 | return pos; | 106 | return pos; |
107 | pos++; | 107 | pos++; |
108 | } | 108 | } |
109 | return -1; | 109 | return -1; |
110 | } | 110 | } |
111 | 111 | ||
112 | QList<Contact>* AddressList::getContactList() | 112 | QList<Contact>* AddressList::getContactList() |
113 | { | 113 | { |
114 | return &addresses; | 114 | return &addresses; |
115 | } | 115 | } |
116 | 116 | ||
117 | void AddressList::read() | 117 | void AddressList::read() |
118 | { | 118 | { |
119 | OContactAccess::List::Iterator it; | 119 | OContactAccess::List::Iterator it; |
120 | 120 | ||
121 | QString lineEmail, lineName, email, name; | 121 | QString lineEmail, lineName, email, name; |
122 | OContactAccess m_contactdb("mailit"); | 122 | OContactAccess m_contactdb("mailit"); |
123 | OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); | 123 | OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); |
124 | //OContact* oc; | 124 | //OContact* oc; |
125 | 125 | ||
126 | for ( it = m_list.begin(); it != m_list.end(); ++it ) | 126 | for ( it = m_list.begin(); it != m_list.end(); ++it ) |
127 | { | 127 | { |
128 | //oc=(OContact*) it; | 128 | //oc=(OContact*) it; |
129 | if ((*it).defaultEmail().length()!=0) | 129 | if ((*it).defaultEmail().length()!=0) |
130 | addContact((*it).defaultEmail(),(*it).fullName()); | 130 | addContact((*it).defaultEmail(),(*it).fileAs()); |
131 | } | 131 | } |
132 | 132 | ||
133 | /*if (! f.open(IO_ReadOnly) ) | 133 | /*if (! f.open(IO_ReadOnly) ) |
134 | return; | 134 | return; |
135 | 135 | ||
136 | QTextStream stream(&f); | 136 | QTextStream stream(&f); |
137 | 137 | ||
138 | while (! stream.atEnd() ) { | 138 | while (! stream.atEnd() ) { |
139 | lineEmail = stream.readLine(); | 139 | lineEmail = stream.readLine(); |
140 | if (! stream.atEnd() ) | 140 | if (! stream.atEnd() ) |
141 | lineName = stream.readLine(); | 141 | lineName = stream.readLine(); |
142 | else return; | 142 | else return; |
143 | 143 | ||
144 | email = getRightString(lineEmail); | 144 | email = getRightString(lineEmail); |
145 | name = getRightString(lineName); | 145 | name = getRightString(lineName); |
146 | addContact(email, name); | 146 | addContact(email, name); |
147 | } | 147 | } |
148 | f.close();*/ | 148 | f.close();*/ |
149 | } | 149 | } |
150 | 150 | ||
151 | QString AddressList::getRightString(QString in) | 151 | QString AddressList::getRightString(QString in) |
152 | { | 152 | { |
153 | QString out = ""; | 153 | QString out = ""; |
154 | 154 | ||
155 | int pos = in.find('='); | 155 | int pos = in.find('='); |
156 | if (pos != -1) { | 156 | if (pos != -1) { |
157 | out = in.mid(pos+1).stripWhiteSpace(); | 157 | out = in.mid(pos+1).stripWhiteSpace(); |
158 | } | 158 | } |
159 | return out; | 159 | return out; |
160 | } | 160 | } |
161 | 161 | ||
diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index 6612541..0d82a9a 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp | |||
@@ -439,252 +439,252 @@ void EmailClient::allMailArrived(int count) | |||
439 | } | 439 | } |
440 | 440 | ||
441 | // all headers downloaded from server, start downloading remaining mails | 441 | // all headers downloaded from server, start downloading remaining mails |
442 | previewingMail = FALSE; | 442 | previewingMail = FALSE; |
443 | status1Label->setText(currentAccount->accountName); | 443 | status1Label->setText(currentAccount->accountName); |
444 | progressBar->reset(); | 444 | progressBar->reset(); |
445 | 445 | ||
446 | emailHandler->getMailByList(&mailDownloadList); | 446 | emailHandler->getMailByList(&mailDownloadList); |
447 | } | 447 | } |
448 | 448 | ||
449 | void EmailClient::moveMailFront(Email *mailPtr) | 449 | void EmailClient::moveMailFront(Email *mailPtr) |
450 | { | 450 | { |
451 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { | 451 | if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { |
452 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); | 452 | mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); |
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | void EmailClient::smtpError(int code) | 456 | void EmailClient::smtpError(int code) |
457 | { | 457 | { |
458 | QString temp; | 458 | QString temp; |
459 | 459 | ||
460 | if (code == ErrUnknownResponse) | 460 | if (code == ErrUnknownResponse) |
461 | temp = "Unknown response from server"; | 461 | temp = "Unknown response from server"; |
462 | 462 | ||
463 | if (code == QSocket::ErrHostNotFound) | 463 | if (code == QSocket::ErrHostNotFound) |
464 | temp = "host not found"; | 464 | temp = "host not found"; |
465 | if (code == QSocket::ErrConnectionRefused) | 465 | if (code == QSocket::ErrConnectionRefused) |
466 | temp = "connection refused"; | 466 | temp = "connection refused"; |
467 | if (code == QSocket::ErrSocketRead) | 467 | if (code == QSocket::ErrSocketRead) |
468 | temp = "socket packet error"; | 468 | temp = "socket packet error"; |
469 | 469 | ||
470 | if (code != ErrCancel) { | 470 | if (code != ErrCancel) { |
471 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); | 471 | QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); |
472 | } else { | 472 | } else { |
473 | status2Label->setText("Aborted by user"); | 473 | status2Label->setText("Aborted by user"); |
474 | } | 474 | } |
475 | 475 | ||
476 | sending = FALSE; | 476 | sending = FALSE; |
477 | sendMailButton->setEnabled(TRUE); | 477 | sendMailButton->setEnabled(TRUE); |
478 | cancelButton->setEnabled(FALSE); | 478 | cancelButton->setEnabled(FALSE); |
479 | quedMessages.clear(); | 479 | quedMessages.clear(); |
480 | } | 480 | } |
481 | 481 | ||
482 | void EmailClient::popError(int code) | 482 | void EmailClient::popError(int code) |
483 | { | 483 | { |
484 | QString temp; | 484 | QString temp; |
485 | 485 | ||
486 | if (code == ErrUnknownResponse) | 486 | if (code == ErrUnknownResponse) |
487 | temp = "Unknown response from server"; | 487 | temp = "Unknown response from server"; |
488 | if (code == ErrLoginFailed) | 488 | if (code == ErrLoginFailed) |
489 | temp = "Login failed\nCheck user name and password"; | 489 | temp = "Login failed\nCheck user name and password"; |
490 | 490 | ||
491 | if (code == QSocket::ErrHostNotFound) | 491 | if (code == QSocket::ErrHostNotFound) |
492 | temp = "host not found"; | 492 | temp = "host not found"; |
493 | if (code == QSocket::ErrConnectionRefused) | 493 | if (code == QSocket::ErrConnectionRefused) |
494 | temp = "connection refused"; | 494 | temp = "connection refused"; |
495 | if (code == QSocket::ErrSocketRead) | 495 | if (code == QSocket::ErrSocketRead) |
496 | temp = "socket packet error"; | 496 | temp = "socket packet error"; |
497 | 497 | ||
498 | if (code != ErrCancel) { | 498 | if (code != ErrCancel) { |
499 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); | 499 | QMessageBox::warning(qApp->activeWindow(), "Receiving error", temp, "OK\n"); |
500 | } else { | 500 | } else { |
501 | status2Label->setText("Aborted by user"); | 501 | status2Label->setText("Aborted by user"); |
502 | } | 502 | } |
503 | 503 | ||
504 | receiving = FALSE; | 504 | receiving = FALSE; |
505 | getMailButton->setEnabled(TRUE); | 505 | getMailButton->setEnabled(TRUE); |
506 | cancelButton->setEnabled(FALSE); | 506 | cancelButton->setEnabled(FALSE); |
507 | selectAccountMenu->setEnabled(TRUE); | 507 | selectAccountMenu->setEnabled(TRUE); |
508 | } | 508 | } |
509 | 509 | ||
510 | void EmailClient::inboxItemSelected() | 510 | void EmailClient::inboxItemSelected() |
511 | { | 511 | { |
512 | item = (EmailListItem*) inboxView->selectedItem(); | 512 | item = (EmailListItem*) inboxView->selectedItem(); |
513 | if (item != NULL) { | 513 | if (item != NULL) { |
514 | emit viewEmail(inboxView, item->getMail()); | 514 | emit viewEmail(inboxView, item->getMail()); |
515 | } | 515 | } |
516 | } | 516 | } |
517 | 517 | ||
518 | void EmailClient::outboxItemSelected() | 518 | void EmailClient::outboxItemSelected() |
519 | { | 519 | { |
520 | item = (EmailListItem*) outboxView->selectedItem(); | 520 | item = (EmailListItem*) outboxView->selectedItem(); |
521 | if (item != NULL) { | 521 | if (item != NULL) { |
522 | emit viewEmail(outboxView, item->getMail()); | 522 | emit viewEmail(outboxView, item->getMail()); |
523 | } | 523 | } |
524 | 524 | ||
525 | } | 525 | } |
526 | 526 | ||
527 | void EmailClient::readMail() | 527 | void EmailClient::readMail() |
528 | { | 528 | { |
529 | Email mail; | 529 | Email mail; |
530 | int start, stop; | 530 | int start, stop; |
531 | QString s, del; | 531 | QString s, del; |
532 | 532 | ||
533 | QFile f(getPath(FALSE) + "inbox.txt"); | 533 | QFile f(getPath(FALSE) + "inbox.txt"); |
534 | // QFileInfo fi(f); | 534 | // QFileInfo fi(f); |
535 | qDebug( f.name()); | 535 | //qDebug( f.name()); |
536 | 536 | ||
537 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 537 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
538 | QTextStream t( &f ); // use a text stream | 538 | QTextStream t( &f ); // use a text stream |
539 | s = t.read(); | 539 | s = t.read(); |
540 | f.close(); | 540 | f.close(); |
541 | 541 | ||
542 | start = 0; | 542 | start = 0; |
543 | del = "\n.\n"; | 543 | del = "\n.\n"; |
544 | while ((uint) start < s.length()) { | 544 | while ((uint) start < s.length()) { |
545 | stop = s.find(del, start); | 545 | stop = s.find(del, start); |
546 | if (stop == -1) | 546 | if (stop == -1) |
547 | stop = s.length() - del.length(); | 547 | stop = s.length() - del.length(); |
548 | 548 | ||
549 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 549 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
550 | start = stop + del.length(); | 550 | start = stop + del.length(); |
551 | mailArrived(mail, TRUE); | 551 | mailArrived(mail, TRUE); |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | QFile fo(getPath(FALSE) + "outbox.txt"); | 555 | QFile fo(getPath(FALSE) + "outbox.txt"); |
556 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully | 556 | if ( fo.open(IO_ReadOnly) ) { // file opened successfully |
557 | QTextStream t( &fo ); // use a text stream | 557 | QTextStream t( &fo ); // use a text stream |
558 | s = t.read(); | 558 | s = t.read(); |
559 | fo.close(); | 559 | fo.close(); |
560 | 560 | ||
561 | start = 0; | 561 | start = 0; |
562 | del = "\n.\n"; | 562 | del = "\n.\n"; |
563 | while ((uint) start < s.length()) { | 563 | while ((uint) start < s.length()) { |
564 | stop = s.find(del, start); | 564 | stop = s.find(del, start); |
565 | if (stop == -1) | 565 | if (stop == -1) |
566 | stop = s.length() - del.length(); | 566 | stop = s.length() - del.length(); |
567 | 567 | ||
568 | mail.rawMail = s.mid(start, stop + del.length() - start ); | 568 | mail.rawMail = s.mid(start, stop + del.length() - start ); |
569 | start = stop + del.length(); | 569 | start = stop + del.length(); |
570 | emailHandler->parse(mail.rawMail, lineShift, &mail); | 570 | emailHandler->parse(mail.rawMail, lineShift, &mail); |
571 | mail.sent = false; | 571 | mail.sent = false; |
572 | mail.received = false; | 572 | mail.received = false; |
573 | enqueMail(mail); | 573 | enqueMail(mail); |
574 | 574 | ||
575 | } | 575 | } |
576 | } | 576 | } |
577 | } | 577 | } |
578 | 578 | ||
579 | void EmailClient::saveMail(QString fileName, QListView *view) | 579 | void EmailClient::saveMail(QString fileName, QListView *view) |
580 | { | 580 | { |
581 | QFile f(fileName); | 581 | QFile f(fileName); |
582 | Email *mail; | 582 | Email *mail; |
583 | 583 | ||
584 | if (! f.open(IO_WriteOnly) ) { | 584 | if (! f.open(IO_WriteOnly) ) { |
585 | qWarning("could not open file"); | 585 | qWarning("could not open file"); |
586 | return; | 586 | return; |
587 | } | 587 | } |
588 | item = (EmailListItem *) view->firstChild(); | 588 | item = (EmailListItem *) view->firstChild(); |
589 | qDebug (QString("Write : ") ); | 589 | //qDebug (QString("Write : ") ); |
590 | QTextStream t(&f); | 590 | QTextStream t(&f); |
591 | while (item != NULL) { | 591 | while (item != NULL) { |
592 | mail = item->getMail(); | 592 | mail = item->getMail(); |
593 | qDebug(mail->rawMail); | 593 | //qDebug(mail->rawMail); |
594 | qDebug(mail->recipients.first()); | 594 | //qDebug(mail->recipients.first()); |
595 | t << mail->rawMail; | 595 | t << mail->rawMail; |
596 | 596 | ||
597 | mailconf->setGroup(mail->id); | 597 | mailconf->setGroup(mail->id); |
598 | mailconf->writeEntry("mailread", mail->read); | 598 | mailconf->writeEntry("mailread", mail->read); |
599 | 599 | ||
600 | item = (EmailListItem *) item->nextSibling(); | 600 | item = (EmailListItem *) item->nextSibling(); |
601 | } | 601 | } |
602 | f.close(); | 602 | f.close(); |
603 | } | 603 | } |
604 | 604 | ||
605 | //paths for mailit, is settings, inbox, enclosures | 605 | //paths for mailit, is settings, inbox, enclosures |
606 | QString EmailClient::getPath(bool enclosurePath) | 606 | QString EmailClient::getPath(bool enclosurePath) |
607 | { | 607 | { |
608 | QString basePath = "qtmail"; | 608 | QString basePath = "qtmail"; |
609 | QString enclosures = "enclosures"; | 609 | QString enclosures = "enclosures"; |
610 | 610 | ||
611 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); | 611 | QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); |
612 | if ( !dir.exists() ) | 612 | if ( !dir.exists() ) |
613 | dir.mkdir( dir.path() ); | 613 | dir.mkdir( dir.path() ); |
614 | 614 | ||
615 | if (enclosurePath) { | 615 | if (enclosurePath) { |
616 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); | 616 | dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); |
617 | 617 | ||
618 | if ( !dir.exists() ) | 618 | if ( !dir.exists() ) |
619 | dir.mkdir( dir.path() ); | 619 | dir.mkdir( dir.path() ); |
620 | 620 | ||
621 | return (dir.path() + "/"); | 621 | return (dir.path() + "/"); |
622 | 622 | ||
623 | } | 623 | } |
624 | return (dir.path() + "/"); | 624 | return (dir.path() + "/"); |
625 | } | 625 | } |
626 | 626 | ||
627 | void EmailClient::readSettings() | 627 | void EmailClient::readSettings() |
628 | { | 628 | { |
629 | TextParser *p; | 629 | TextParser *p; |
630 | QString s; | 630 | QString s; |
631 | int pos, accountPos, y; | 631 | int pos, accountPos, y; |
632 | QFile f( getPath(FALSE) + "settings.txt"); | 632 | QFile f( getPath(FALSE) + "settings.txt"); |
633 | 633 | ||
634 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 634 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
635 | QTextStream t( &f ); // use a text stream | 635 | QTextStream t( &f ); // use a text stream |
636 | s = t.read(); | 636 | s = t.read(); |
637 | f.close(); | 637 | f.close(); |
638 | 638 | ||
639 | p = new TextParser(s, "\n"); | 639 | p = new TextParser(s, "\n"); |
640 | 640 | ||
641 | accountPos = 0; | 641 | accountPos = 0; |
642 | while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { | 642 | while ( (accountPos = p->find("ACCOUNTSTART",';', accountPos, TRUE)) != -1 ) { |
643 | accountPos++; | 643 | accountPos++; |
644 | if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) | 644 | if ( (pos = p->find("ACCOUNTNAME",':', accountPos, TRUE)) != -1 ) |
645 | account.accountName = p->getString(& ++pos, 'z', TRUE); | 645 | account.accountName = p->getString(& ++pos, 'z', TRUE); |
646 | if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) | 646 | if ( (pos = p->find("NAME",':', accountPos, TRUE)) != -1) |
647 | account.name = p->getString(& ++pos, 'z', TRUE); | 647 | account.name = p->getString(& ++pos, 'z', TRUE); |
648 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) | 648 | if ( (pos = p->find("EMAIL",':', accountPos, TRUE)) != -1) |
649 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); | 649 | account.emailAddress = p->getString(& ++pos, 'z', TRUE); |
650 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) | 650 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) |
651 | account.popUserName = p->getString(& ++pos, 'z', TRUE); | 651 | account.popUserName = p->getString(& ++pos, 'z', TRUE); |
652 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) | 652 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) |
653 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); | 653 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); |
654 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) | 654 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) |
655 | account.popServer = p->getString(& ++pos, 'z', TRUE); | 655 | account.popServer = p->getString(& ++pos, 'z', TRUE); |
656 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) | 656 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) |
657 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); | 657 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); |
658 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { | 658 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { |
659 | s = p->getString(& ++pos, 'z', TRUE); | 659 | s = p->getString(& ++pos, 'z', TRUE); |
660 | account.id = s.toInt(); | 660 | account.id = s.toInt(); |
661 | } | 661 | } |
662 | 662 | ||
663 | account.lastServerMailCount = 0; | 663 | account.lastServerMailCount = 0; |
664 | account.synchronize = FALSE; | 664 | account.synchronize = FALSE; |
665 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { | 665 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { |
666 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { | 666 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { |
667 | account.synchronize = TRUE; | 667 | account.synchronize = TRUE; |
668 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { | 668 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { |
669 | s = p->getString(& ++pos, 'z', TRUE); | 669 | s = p->getString(& ++pos, 'z', TRUE); |
670 | account.lastServerMailCount = s.toInt(); | 670 | account.lastServerMailCount = s.toInt(); |
671 | } | 671 | } |
672 | } | 672 | } |
673 | } | 673 | } |
674 | 674 | ||
675 | if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { | 675 | if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { |
676 | account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); | 676 | account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); |
677 | } | 677 | } |
678 | 678 | ||
679 | 679 | ||
680 | accountList.append(&account); | 680 | accountList.append(&account); |
681 | } | 681 | } |
682 | delete p; | 682 | delete p; |
683 | } | 683 | } |
684 | mailconf->setGroup("mailitglobal"); | 684 | mailconf->setGroup("mailitglobal"); |
685 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { | 685 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { |
686 | mailIdCount = y; | 686 | mailIdCount = y; |
687 | } | 687 | } |
688 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { | 688 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { |
689 | accountIdCount = y; | 689 | accountIdCount = y; |
690 | } | 690 | } |
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp index 9c1c814..03f8a28 100644 --- a/noncore/unsupported/mailit/emailhandler.cpp +++ b/noncore/unsupported/mailit/emailhandler.cpp | |||
@@ -70,194 +70,192 @@ void EmailHandler::sendMail(QList<Email> *mailList) | |||
70 | Email *currentMail; | 70 | Email *currentMail; |
71 | QString temp; | 71 | QString temp; |
72 | QString userName = mailAccount.name; | 72 | QString userName = mailAccount.name; |
73 | userName += " <" + mailAccount.emailAddress + ">"; | 73 | userName += " <" + mailAccount.emailAddress + ">"; |
74 | 74 | ||
75 | for (currentMail = mailList->first(); currentMail != 0; | 75 | for (currentMail = mailList->first(); currentMail != 0; |
76 | currentMail = mailList->next()) { | 76 | currentMail = mailList->next()) { |
77 | 77 | ||
78 | if (encodeMime(currentMail) == 0) { | 78 | if (encodeMime(currentMail) == 0) { |
79 | smtpClient->addMail(userName, currentMail->subject, | 79 | smtpClient->addMail(userName, currentMail->subject, |
80 | currentMail->recipients, currentMail->rawMail); | 80 | currentMail->recipients, currentMail->rawMail); |
81 | } else { //error | 81 | } else { //error |
82 | temp = tr("Could not locate all files in \nmail with subject: ") + | 82 | temp = tr("Could not locate all files in \nmail with subject: ") + |
83 | currentMail->subject; | 83 | currentMail->subject; |
84 | temp += tr("\nMail has NOT been sent"); | 84 | temp += tr("\nMail has NOT been sent"); |
85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); | 85 | QMessageBox::warning(qApp->activeWindow(), tr("Attachment error"), temp, tr("OK\n")); |
86 | 86 | ||
87 | } | 87 | } |
88 | } | 88 | } |
89 | smtpClient->newConnection(mailAccount.smtpServer, 25); | 89 | smtpClient->newConnection(mailAccount.smtpServer, 25); |
90 | } | 90 | } |
91 | 91 | ||
92 | void EmailHandler::setAccount(MailAccount account) | 92 | void EmailHandler::setAccount(MailAccount account) |
93 | { | 93 | { |
94 | mailAccount = account; | 94 | mailAccount = account; |
95 | } | 95 | } |
96 | 96 | ||
97 | void EmailHandler::getMail() | 97 | void EmailHandler::getMail() |
98 | { | 98 | { |
99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
100 | if (mailAccount.synchronize) { | 100 | if (mailAccount.synchronize) { |
101 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 101 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
102 | } else { | 102 | } else { |
103 | popClient->removeSynchronize(); | 103 | popClient->removeSynchronize(); |
104 | } | 104 | } |
105 | 105 | ||
106 | headers = FALSE; | 106 | headers = FALSE; |
107 | popClient->headersOnly(headers, 0); | 107 | popClient->headersOnly(headers, 0); |
108 | popClient->newConnection(mailAccount.popServer, 110); | 108 | popClient->newConnection(mailAccount.popServer, 110); |
109 | } | 109 | } |
110 | 110 | ||
111 | void EmailHandler::getMailHeaders() | 111 | void EmailHandler::getMailHeaders() |
112 | { | 112 | { |
113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
114 | if (mailAccount.synchronize) { | 114 | if (mailAccount.synchronize) { |
115 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 115 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
116 | } else { | 116 | } else { |
117 | popClient->removeSynchronize(); | 117 | popClient->removeSynchronize(); |
118 | } | 118 | } |
119 | 119 | ||
120 | headers = TRUE; | 120 | headers = TRUE; |
121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all | 121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all |
122 | popClient->newConnection(mailAccount.popServer, 110); | 122 | popClient->newConnection(mailAccount.popServer, 110); |
123 | } | 123 | } |
124 | 124 | ||
125 | void EmailHandler::getMailByList(MailList *mailList) | 125 | void EmailHandler::getMailByList(MailList *mailList) |
126 | { | 126 | { |
127 | if (mailList->count() == 0) { //should not occur though | 127 | if (mailList->count() == 0) { //should not occur though |
128 | emit mailTransfered(0); | 128 | emit mailTransfered(0); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | 131 | ||
132 | headers = FALSE; | 132 | headers = FALSE; |
133 | popClient->headersOnly(FALSE, 0); | 133 | popClient->headersOnly(FALSE, 0); |
134 | popClient->newConnection(mailAccount.popServer, 110); | 134 | popClient->newConnection(mailAccount.popServer, 110); |
135 | popClient->setSelectedMails(mailList); | 135 | popClient->setSelectedMails(mailList); |
136 | } | 136 | } |
137 | 137 | ||
138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) | 138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) |
139 | { | 139 | { |
140 | Email mail; | 140 | Email mail; |
141 | 141 | ||
142 | mail.rawMail = message; | 142 | mail.rawMail = message; |
143 | mail.serverId = id; | 143 | mail.serverId = id; |
144 | mail.size = size; | 144 | mail.size = size; |
145 | mail.downloaded = complete; | 145 | mail.downloaded = complete; |
146 | 146 | ||
147 | emit mailArrived(mail, FALSE); | 147 | emit mailArrived(mail, FALSE); |
148 | } | 148 | } |
149 | 149 | ||
150 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | 150 | bool EmailHandler::parse(QString in, QString lineShift, Email *mail) |
151 | { | 151 | { |
152 | QString temp, boundary; | 152 | QString temp, boundary; |
153 | int pos; | 153 | int pos; |
154 | QString delimiter, header, body, mimeHeader, mimeBody; | 154 | QString delimiter, header, body, mimeHeader, mimeBody; |
155 | QString content, contentType, contentAttribute, id, encoding; | 155 | QString content, contentType, contentAttribute, id, encoding; |
156 | QString fileName, storedName; | 156 | QString fileName, storedName; |
157 | int enclosureId = 0; | 157 | int enclosureId = 0; |
158 | 158 | ||
159 | mail->rawMail = in; | 159 | mail->rawMail = in; |
160 | mail->received = TRUE; | 160 | mail->received = TRUE; |
161 | mail->files.setAutoDelete(TRUE); | 161 | mail->files.setAutoDelete(TRUE); |
162 | 162 | ||
163 | temp = lineShift + "." + lineShift; | 163 | temp = lineShift + "." + lineShift; |
164 | 164 | ||
165 | if (in.right(temp.length()) != temp) { | 165 | if (in.right(temp.length()) != temp) { |
166 | qWarning(in.right(temp.length())); | ||
167 | qWarning(" . added at end of email as separator"); | ||
168 | mail->rawMail += temp; | 166 | mail->rawMail += temp; |
169 | } | 167 | } |
170 | 168 | ||
171 | 169 | ||
172 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" | 170 | delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" |
173 | pos = in.find(delimiter, 0, FALSE); | 171 | pos = in.find(delimiter, 0, FALSE); |
174 | header = in.left(pos); | 172 | header = in.left(pos); |
175 | body = in.right(in.length() - pos - delimiter.length()); | 173 | body = in.right(in.length() - pos - delimiter.length()); |
176 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) | 174 | if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) |
177 | body.truncate(body.length()-2); | 175 | body.truncate(body.length()-2); |
178 | 176 | ||
179 | TextParser p(header, lineShift); | 177 | TextParser p(header, lineShift); |
180 | 178 | ||
181 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { | 179 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { |
182 | pos++; | 180 | pos++; |
183 | if (p.separatorAt(pos) == ' ') { | 181 | if (p.separatorAt(pos) == ' ') { |
184 | mail->from = p.getString(&pos, '<', false); | 182 | mail->from = p.getString(&pos, '<', false); |
185 | mail->from = mail->from.stripWhiteSpace(); | 183 | mail->from = mail->from.stripWhiteSpace(); |
186 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { | 184 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { |
187 | mail->from = mail->from.left(mail->from.length() - 1); | 185 | mail->from = mail->from.left(mail->from.length() - 1); |
188 | mail->from = mail->from.right(mail->from.length() - 1); | 186 | mail->from = mail->from.right(mail->from.length() - 1); |
189 | } | 187 | } |
190 | pos++; | 188 | pos++; |
191 | mail->fromMail = p.getString(&pos, '>', false); | 189 | mail->fromMail = p.getString(&pos, '>', false); |
192 | } else { | 190 | } else { |
193 | if ((p.separatorAt(pos) == '<') | 191 | if ((p.separatorAt(pos) == '<') |
194 | || (p.separatorAt(pos) == ' ')) //No name.. nasty | 192 | || (p.separatorAt(pos) == ' ')) //No name.. nasty |
195 | pos++; | 193 | pos++; |
196 | pos++; | 194 | pos++; |
197 | mail->fromMail = p.getString(&pos, 'z', TRUE); | 195 | mail->fromMail = p.getString(&pos, 'z', TRUE); |
198 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | 196 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') |
199 | mail->fromMail.truncate(mail->fromMail.length() - 1); | 197 | mail->fromMail.truncate(mail->fromMail.length() - 1); |
200 | mail->from=mail->fromMail; | 198 | mail->from=mail->fromMail; |
201 | } | 199 | } |
202 | } | 200 | } |
203 | 201 | ||
204 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: | 202 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: |
205 | if (pos = p.find("TO",':', pos, TRUE) != -1) | 203 | if (pos = p.find("TO",':', pos, TRUE) != -1) |
206 | { | 204 | { |
207 | pos++; | 205 | pos++; |
208 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | 206 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); |
209 | } | 207 | } |
210 | 208 | ||
211 | 209 | ||
212 | 210 | ||
213 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { | 211 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { |
214 | pos++; | 212 | pos++; |
215 | mail->subject = p.getString(&pos, 'z', TRUE); | 213 | mail->subject = p.getString(&pos, 'z', TRUE); |
216 | } | 214 | } |
217 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { | 215 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { |
218 | pos++; | 216 | pos++; |
219 | mail->date = p.getString(&pos, 'z', true); | 217 | mail->date = p.getString(&pos, 'z', true); |
220 | } | 218 | } |
221 | 219 | ||
222 | 220 | ||
223 | 221 | ||
224 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { | 222 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { |
225 | pos++; | 223 | pos++; |
226 | if ( (p.wordAt(pos).upper() == "ID") && | 224 | if ( (p.wordAt(pos).upper() == "ID") && |
227 | (p.separatorAt(pos) == ':') ) { | 225 | (p.separatorAt(pos) == ':') ) { |
228 | 226 | ||
229 | id = p.getString(&pos, 'z', TRUE); | 227 | id = p.getString(&pos, 'z', TRUE); |
230 | mail->id = id; | 228 | mail->id = id; |
231 | } | 229 | } |
232 | } | 230 | } |
233 | 231 | ||
234 | pos = 0; | 232 | pos = 0; |
235 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { | 233 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { |
236 | pos++; | 234 | pos++; |
237 | if ( (p.wordAt(pos).upper() == "VERSION") && | 235 | if ( (p.wordAt(pos).upper() == "VERSION") && |
238 | (p.separatorAt(pos) == ':') ) { | 236 | (p.separatorAt(pos) == ':') ) { |
239 | pos++; | 237 | pos++; |
240 | if (p.getString(&pos, 'z', true) == "1.0") { | 238 | if (p.getString(&pos, 'z', true) == "1.0") { |
241 | mail->mimeType = 1; | 239 | mail->mimeType = 1; |
242 | } | 240 | } |
243 | } | 241 | } |
244 | } | 242 | } |
245 | 243 | ||
246 | if (mail->mimeType == 1) { | 244 | if (mail->mimeType == 1) { |
247 | boundary = ""; | 245 | boundary = ""; |
248 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { | 246 | if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { |
249 | pos++; | 247 | pos++; |
250 | boundary = p.getString(&pos, 'z', true); | 248 | boundary = p.getString(&pos, 'z', true); |
251 | if (boundary[0] == '"') { | 249 | if (boundary[0] == '"') { |
252 | boundary = boundary.left(boundary.length() - 1); //strip " | 250 | boundary = boundary.left(boundary.length() - 1); //strip " |
253 | boundary = boundary.right(boundary.length() - 1); //strip " | 251 | boundary = boundary.right(boundary.length() - 1); //strip " |
254 | } | 252 | } |
255 | boundary = "--" + boundary; //create boundary field | 253 | boundary = "--" + boundary; //create boundary field |
256 | } | 254 | } |
257 | 255 | ||
258 | if (boundary == "") { //fooled by Mime-Version | 256 | if (boundary == "") { //fooled by Mime-Version |
259 | mail->body = body; | 257 | mail->body = body; |
260 | mail->bodyPlain = body; | 258 | mail->bodyPlain = body; |
261 | return mail; | 259 | return mail; |
262 | } | 260 | } |
263 | 261 | ||
diff --git a/noncore/unsupported/mailit/mailitwindow.cpp b/noncore/unsupported/mailit/mailitwindow.cpp index fd49c1f..2bf1dcb 100644 --- a/noncore/unsupported/mailit/mailitwindow.cpp +++ b/noncore/unsupported/mailit/mailitwindow.cpp | |||
@@ -1,136 +1,133 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "mailitwindow.h" | 20 | #include "mailitwindow.h" |
21 | 21 | ||
22 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) | 22 | MailItWindow::MailItWindow(QWidget *parent, const char *name, WFlags fl) |
23 | : QMainWindow(parent, name, fl) | 23 | : QMainWindow(parent, name, fl) |
24 | { | 24 | { |
25 | currentCaption = "Mailit"; | 25 | currentCaption = "Mailit"; |
26 | setCaption(tr(currentCaption)); | 26 | setCaption(tr(currentCaption)); |
27 | views = new QWidgetStack(this); | 27 | views = new QWidgetStack(this); |
28 | setCentralWidget(views); | 28 | setCentralWidget(views); |
29 | 29 | ||
30 | qWarning("***Starting writeMail"); | ||
31 | emailClient = new EmailClient(views, "client"); | 30 | emailClient = new EmailClient(views, "client"); |
32 | writeMail = new WriteMail(views, "writing"); | 31 | writeMail = new WriteMail(views, "writing"); |
33 | readMail = new ReadMail(views, "reading"); | 32 | readMail = new ReadMail(views, "reading"); |
34 | qWarning("***Finished readMail"); | ||
35 | 33 | ||
36 | views->raiseWidget(emailClient); | 34 | views->raiseWidget(emailClient); |
37 | 35 | ||
38 | connect(emailClient, SIGNAL(composeRequested()), | 36 | connect(emailClient, SIGNAL(composeRequested()), |
39 | this, SLOT(compose()) ); | 37 | this, SLOT(compose()) ); |
40 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, | 38 | connect(emailClient, SIGNAL(viewEmail(QListView *, Email *)), this, |
41 | SLOT(viewMail(QListView *, Email *)) ); | 39 | SLOT(viewMail(QListView *, Email *)) ); |
42 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, | 40 | connect(emailClient, SIGNAL(mailUpdated(Email *)), this, |
43 | SLOT(updateMailView(Email *)) ); | 41 | SLOT(updateMailView(Email *)) ); |
44 | 42 | ||
45 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); | 43 | connect(writeMail, SIGNAL(cancelMail()), this, SLOT(showEmailClient()) ); |
46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, | 44 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), this, |
47 | SLOT(showEmailClient()) ); | 45 | SLOT(showEmailClient()) ); |
48 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, | 46 | connect(writeMail, SIGNAL(sendMailRequested(const Email &)), emailClient, |
49 | SLOT(enqueMail(const Email &)) ); | 47 | SLOT(enqueMail(const Email &)) ); |
50 | 48 | ||
51 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); | 49 | connect(readMail, SIGNAL(cancelView()), this, SLOT(showEmailClient()) ); |
52 | connect(readMail, SIGNAL(replyRequested(Email &)), this, | 50 | connect(readMail, SIGNAL(replyRequested(Email &)), this, |
53 | SLOT(composeReply(Email &)) ); | 51 | SLOT(composeReply(Email &)) ); |
54 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, | 52 | connect(readMail, SIGNAL(removeItem(EmailListItem *, bool &)), emailClient, |
55 | SLOT(deleteMail(EmailListItem *, bool &)) ); | 53 | SLOT(deleteMail(EmailListItem *, bool &)) ); |
56 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, | 54 | connect(readMail, SIGNAL(viewingMail(Email *)), emailClient, |
57 | SLOT(moveMailFront(Email *)) ); | 55 | SLOT(moveMailFront(Email *)) ); |
58 | 56 | ||
59 | connect(emailClient, SIGNAL(newCaption(const QString &)), | 57 | connect(emailClient, SIGNAL(newCaption(const QString &)), |
60 | this, SLOT(updateCaption(const QString &)) ); | 58 | this, SLOT(updateCaption(const QString &)) ); |
61 | viewingMail = FALSE; | 59 | viewingMail = FALSE; |
62 | 60 | ||
63 | qWarning("***Finished MailitWindow"); | ||
64 | } | 61 | } |
65 | 62 | ||
66 | MailItWindow::~MailItWindow() | 63 | MailItWindow::~MailItWindow() |
67 | { | 64 | { |
68 | } | 65 | } |
69 | 66 | ||
70 | void MailItWindow::closeEvent(QCloseEvent *e) | 67 | void MailItWindow::closeEvent(QCloseEvent *e) |
71 | { | 68 | { |
72 | if (views->visibleWidget() == emailClient) { | 69 | if (views->visibleWidget() == emailClient) { |
73 | e->accept(); | 70 | e->accept(); |
74 | } else { | 71 | } else { |
75 | showEmailClient(); | 72 | showEmailClient(); |
76 | } | 73 | } |
77 | } | 74 | } |
78 | 75 | ||
79 | void MailItWindow::compose() | 76 | void MailItWindow::compose() |
80 | { | 77 | { |
81 | viewingMail = FALSE; | 78 | viewingMail = FALSE; |
82 | emailClient->hide(); | 79 | emailClient->hide(); |
83 | readMail->hide(); | 80 | readMail->hide(); |
84 | views->raiseWidget(writeMail); | 81 | views->raiseWidget(writeMail); |
85 | writeMail->setAddressList(emailClient->getAdrListRef()); | 82 | writeMail->setAddressList(emailClient->getAdrListRef()); |
86 | setCaption( tr( "Write mail" ) ); | 83 | setCaption( tr( "Write mail" ) ); |
87 | } | 84 | } |
88 | 85 | ||
89 | void MailItWindow::composeReply(Email &mail) | 86 | void MailItWindow::composeReply(Email &mail) |
90 | { | 87 | { |
91 | compose(); | 88 | compose(); |
92 | writeMail->reply(mail); | 89 | writeMail->reply(mail); |
93 | } | 90 | } |
94 | 91 | ||
95 | void MailItWindow::showEmailClient() | 92 | void MailItWindow::showEmailClient() |
96 | { | 93 | { |
97 | viewingMail = FALSE; | 94 | viewingMail = FALSE; |
98 | writeMail->hide(); | 95 | writeMail->hide(); |
99 | readMail->hide(); | 96 | readMail->hide(); |
100 | views->raiseWidget(emailClient); | 97 | views->raiseWidget(emailClient); |
101 | setCaption( tr(currentCaption) ); | 98 | setCaption( tr(currentCaption) ); |
102 | } | 99 | } |
103 | 100 | ||
104 | void MailItWindow::viewMail(QListView *view, Email *mail) | 101 | void MailItWindow::viewMail(QListView *view, Email *mail) |
105 | { | 102 | { |
106 | viewingMail = TRUE; | 103 | viewingMail = TRUE; |
107 | emailClient->hide(); | 104 | emailClient->hide(); |
108 | readMail->update(view, mail); | 105 | readMail->update(view, mail); |
109 | views->raiseWidget(readMail); | 106 | views->raiseWidget(readMail); |
110 | setCaption( tr( "Examine mail" ) ); | 107 | setCaption( tr( "Examine mail" ) ); |
111 | } | 108 | } |
112 | 109 | ||
113 | void MailItWindow::updateMailView(Email *mail) | 110 | void MailItWindow::updateMailView(Email *mail) |
114 | { | 111 | { |
115 | if (viewingMail) { | 112 | if (viewingMail) { |
116 | readMail->mailUpdated(mail); | 113 | readMail->mailUpdated(mail); |
117 | } | 114 | } |
118 | } | 115 | } |
119 | 116 | ||
120 | void MailItWindow::updateCaption(const QString &newCaption) | 117 | void MailItWindow::updateCaption(const QString &newCaption) |
121 | { | 118 | { |
122 | currentCaption = newCaption; | 119 | currentCaption = newCaption; |
123 | setCaption(tr(currentCaption)); | 120 | setCaption(tr(currentCaption)); |
124 | } | 121 | } |
125 | 122 | ||
126 | void MailItWindow::setDocument(const QString &_address) | 123 | void MailItWindow::setDocument(const QString &_address) |
127 | { | 124 | { |
128 | // strip leading 'mailto:' | 125 | // strip leading 'mailto:' |
129 | QString address = _address; | 126 | QString address = _address; |
130 | if (address.startsWith("mailto:")) | 127 | if (address.startsWith("mailto:")) |
131 | address = address.mid(6); | 128 | address = address.mid(6); |
132 | 129 | ||
133 | compose(); | 130 | compose(); |
134 | writeMail->setRecipient(address); | 131 | writeMail->setRecipient(address); |
135 | } | 132 | } |
136 | 133 | ||
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp index 2f14ed2..f9cc337 100644 --- a/noncore/unsupported/mailit/popclient.cpp +++ b/noncore/unsupported/mailit/popclient.cpp | |||
@@ -26,350 +26,350 @@ extern "C" { | |||
26 | } | 26 | } |
27 | 27 | ||
28 | #include <qcstring.h> | 28 | #include <qcstring.h> |
29 | 29 | ||
30 | PopClient::PopClient() | 30 | PopClient::PopClient() |
31 | { | 31 | { |
32 | socket = new QSocket(this, "popClient"); | 32 | socket = new QSocket(this, "popClient"); |
33 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); | 33 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); |
34 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); | 34 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); |
35 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); | 35 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); |
36 | 36 | ||
37 | stream = new QTextStream(socket); | 37 | stream = new QTextStream(socket); |
38 | 38 | ||
39 | receiving = FALSE; | 39 | receiving = FALSE; |
40 | synchronize = FALSE; | 40 | synchronize = FALSE; |
41 | lastSync = 0; | 41 | lastSync = 0; |
42 | headerLimit = 0; | 42 | headerLimit = 0; |
43 | preview = FALSE; | 43 | preview = FALSE; |
44 | } | 44 | } |
45 | 45 | ||
46 | PopClient::~PopClient() | 46 | PopClient::~PopClient() |
47 | { | 47 | { |
48 | delete socket; | 48 | delete socket; |
49 | delete stream; | 49 | delete stream; |
50 | } | 50 | } |
51 | 51 | ||
52 | void PopClient::newConnection(QString target, int port) | 52 | void PopClient::newConnection(QString target, int port) |
53 | { | 53 | { |
54 | if (receiving) { | 54 | if (receiving) { |
55 | qWarning("socket in use, connection refused"); | 55 | qWarning("socket in use, connection refused"); |
56 | return; | 56 | return; |
57 | } | 57 | } |
58 | 58 | ||
59 | status = Init; | 59 | status = Init; |
60 | 60 | ||
61 | socket->connectToHost(target, port); | 61 | socket->connectToHost(target, port); |
62 | receiving = TRUE; | 62 | receiving = TRUE; |
63 | selected = FALSE; | 63 | selected = FALSE; |
64 | 64 | ||
65 | emit updateStatus("DNS lookup"); | 65 | emit updateStatus("DNS lookup"); |
66 | } | 66 | } |
67 | 67 | ||
68 | void PopClient::setAccount(QString popUser, QString popPasswd) | 68 | void PopClient::setAccount(QString popUser, QString popPasswd) |
69 | { | 69 | { |
70 | popUserName = popUser; | 70 | popUserName = popUser; |
71 | popPassword = popPasswd; | 71 | popPassword = popPasswd; |
72 | } | 72 | } |
73 | 73 | ||
74 | void PopClient::setSynchronize(int lastCount) | 74 | void PopClient::setSynchronize(int lastCount) |
75 | { | 75 | { |
76 | synchronize = TRUE; | 76 | synchronize = TRUE; |
77 | lastSync = lastCount; | 77 | lastSync = lastCount; |
78 | } | 78 | } |
79 | 79 | ||
80 | void PopClient::removeSynchronize() | 80 | void PopClient::removeSynchronize() |
81 | { | 81 | { |
82 | synchronize = FALSE; | 82 | synchronize = FALSE; |
83 | lastSync = 0; | 83 | lastSync = 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | void PopClient::headersOnly(bool headers, int limit) | 86 | void PopClient::headersOnly(bool headers, int limit) |
87 | { | 87 | { |
88 | preview = headers; | 88 | preview = headers; |
89 | headerLimit = limit; | 89 | headerLimit = limit; |
90 | } | 90 | } |
91 | 91 | ||
92 | void PopClient::setSelectedMails(MailList *list) | 92 | void PopClient::setSelectedMails(MailList *list) |
93 | { | 93 | { |
94 | selected = TRUE; | 94 | selected = TRUE; |
95 | mailList = list; | 95 | mailList = list; |
96 | } | 96 | } |
97 | 97 | ||
98 | void PopClient::connectionEstablished() | 98 | void PopClient::connectionEstablished() |
99 | { | 99 | { |
100 | emit updateStatus(tr("Connection established")); | 100 | emit updateStatus(tr("Connection established")); |
101 | } | 101 | } |
102 | 102 | ||
103 | void PopClient::errorHandling(int status) | 103 | void PopClient::errorHandling(int status) |
104 | { | 104 | { |
105 | emit updateStatus(tr("Error Occured")); | 105 | emit updateStatus(tr("Error Occured")); |
106 | emit errorOccurred(status); | 106 | emit errorOccurred(status); |
107 | socket->close(); | 107 | socket->close(); |
108 | receiving = FALSE; | 108 | receiving = FALSE; |
109 | } | 109 | } |
110 | 110 | ||
111 | void PopClient::incomingData() | 111 | void PopClient::incomingData() |
112 | { | 112 | { |
113 | QString response, temp, temp2, timeStamp; | 113 | QString response, temp, temp2, timeStamp; |
114 | QString md5Source; | 114 | QString md5Source; |
115 | int start, end; | 115 | int start, end; |
116 | // char *md5Digest; | 116 | // char *md5Digest; |
117 | char md5Digest[16]; | 117 | char md5Digest[16]; |
118 | // if ( !socket->canReadLine() ) | 118 | // if ( !socket->canReadLine() ) |
119 | // return; | 119 | // return; |
120 | 120 | ||
121 | response = socket->readLine(); | 121 | response = socket->readLine(); |
122 | qDebug(response +" %d", status); | 122 | //qDebug(response +" %d", status); |
123 | 123 | ||
124 | switch(status) { | 124 | switch(status) { |
125 | //logging in | 125 | //logging in |
126 | case Init: { | 126 | case Init: { |
127 | #ifdef APOP_TEST | 127 | #ifdef APOP_TEST |
128 | start = response.find('<',0); | 128 | start = response.find('<',0); |
129 | end = response.find('>', start); | 129 | end = response.find('>', start); |
130 | if( start >= 0 && end > start ) | 130 | if( start >= 0 && end > start ) |
131 | { | 131 | { |
132 | timeStamp = response.mid( start , end - start + 1); | 132 | timeStamp = response.mid( start , end - start + 1); |
133 | md5Source = timeStamp + popPassword; | 133 | md5Source = timeStamp + popPassword; |
134 | qDebug( md5Source); | 134 | //qDebug( md5Source); |
135 | // for( int i = 0; i < md5Source.length(); i++) { | 135 | // for( int i = 0; i < md5Source.length(); i++) { |
136 | // buff[i] = (QChar)md5Source[i]; | 136 | // buff[i] = (QChar)md5Source[i]; |
137 | // } | 137 | // } |
138 | 138 | ||
139 | md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); | 139 | md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); |
140 | // md5_buffer(char const *buffer, unsigned int len, char *digest); | 140 | // md5_buffer(char const *buffer, unsigned int len, char *digest); |
141 | 141 | ||
142 | // MD5_Init( &ctx); | 142 | // MD5_Init( &ctx); |
143 | // MD5_Update( &ctx, buff, sizeof( buff) ); | 143 | // MD5_Update( &ctx, buff, sizeof( buff) ); |
144 | // MD5_Final( md5Digest, &ctx); | 144 | // MD5_Final( md5Digest, &ctx); |
145 | // MD5( buff, md5Source.length(), md5Digest); | 145 | // MD5( buff, md5Source.length(), md5Digest); |
146 | 146 | ||
147 | for(int j =0;j < MD5_DIGEST_LENGTH ;j++) | 147 | for(int j =0;j < MD5_DIGEST_LENGTH ;j++) |
148 | { | 148 | { |
149 | printf("%x", md5Digest[j]); | 149 | printf("%x", md5Digest[j]); |
150 | } | 150 | } |
151 | printf("\n"); | 151 | printf("\n"); |
152 | // qDebug(md5Digest); | 152 | // qDebug(md5Digest); |
153 | *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; | 153 | *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; |
154 | // qDebug("%s", stream); | 154 | // qDebug("%s", stream); |
155 | status = Stat; | 155 | status = Stat; |
156 | } | 156 | } |
157 | else | 157 | else |
158 | #endif | 158 | #endif |
159 | { | 159 | { |
160 | timeStamp = ""; | 160 | timeStamp = ""; |
161 | *stream << "USER " << popUserName << "\r\n"; | 161 | *stream << "USER " << popUserName << "\r\n"; |
162 | status = Pass; | 162 | status = Pass; |
163 | } | 163 | } |
164 | 164 | ||
165 | break; | 165 | break; |
166 | } | 166 | } |
167 | //password shhh. don't tell anyone (implement APOP...) | 167 | //password shhh. don't tell anyone (implement APOP...) |
168 | case Pass: { | 168 | case Pass: { |
169 | *stream << "PASS " << popPassword << "\r\n"; | 169 | *stream << "PASS " << popPassword << "\r\n"; |
170 | status = Stat; | 170 | status = Stat; |
171 | break; | 171 | break; |
172 | } | 172 | } |
173 | //ask for number of messages | 173 | //ask for number of messages |
174 | case Stat: { | 174 | case Stat: { |
175 | if (response[0] == '+') { | 175 | if (response[0] == '+') { |
176 | *stream << "STAT" << "\r\n"; | 176 | *stream << "STAT" << "\r\n"; |
177 | status = Mcnt; | 177 | status = Mcnt; |
178 | } else errorHandling(ErrLoginFailed); | 178 | } else errorHandling(ErrLoginFailed); |
179 | break; | 179 | break; |
180 | } | 180 | } |
181 | //get count of messages, eg "+OK 4 900.." -> int 4 | 181 | //get count of messages, eg "+OK 4 900.." -> int 4 |
182 | case Mcnt: { | 182 | case Mcnt: { |
183 | if (response[0] == '+') { | 183 | if (response[0] == '+') { |
184 | temp = response.replace(0, 4, ""); | 184 | temp = response.replace(0, 4, ""); |
185 | int x = temp.find(" ", 0); | 185 | int x = temp.find(" ", 0); |
186 | temp.truncate((uint) x); | 186 | temp.truncate((uint) x); |
187 | newMessages = temp.toInt(); | 187 | newMessages = temp.toInt(); |
188 | messageCount = 1; | 188 | messageCount = 1; |
189 | status = List; | 189 | status = List; |
190 | 190 | ||
191 | if (synchronize) { | 191 | if (synchronize) { |
192 | //messages deleted from server, reload all | 192 | //messages deleted from server, reload all |
193 | if (newMessages < lastSync) | 193 | if (newMessages < lastSync) |
194 | lastSync = 0; | 194 | lastSync = 0; |
195 | messageCount = lastSync + 1; | 195 | messageCount = 1; |
196 | } | 196 | } |
197 | 197 | ||
198 | if (selected) { | 198 | if (selected) { |
199 | int *ptr = mailList->first(); | 199 | int *ptr = mailList->first(); |
200 | if (ptr != 0) { | 200 | if (ptr != 0) { |
201 | newMessages++; //to ensure no early jumpout | 201 | newMessages++; //to ensure no early jumpout |
202 | messageCount = *(mailList->first()); | 202 | messageCount = *(mailList->first()); |
203 | } else newMessages = 0; | 203 | } else newMessages = 0; |
204 | } | 204 | } |
205 | } else errorHandling(ErrUnknownResponse); | 205 | } else errorHandling(ErrUnknownResponse); |
206 | } | 206 | } |
207 | //Read message number x, count upwards to messageCount | 207 | //Read message number x, count upwards to messageCount |
208 | case List: { | 208 | case List: { |
209 | if (messageCount <= newMessages) { | 209 | if (messageCount <= newMessages) { |
210 | *stream << "LIST " << messageCount << "\r\n"; | 210 | *stream << "LIST " << messageCount << "\r\n"; |
211 | status = Size; | 211 | status = Size; |
212 | temp2.setNum(newMessages - lastSync); | 212 | temp2.setNum(newMessages - lastSync); |
213 | temp.setNum(messageCount - lastSync); | 213 | temp.setNum(messageCount - lastSync); |
214 | if (!selected) { | 214 | if (!selected) { |
215 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); | 215 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
216 | } else { | 216 | } else { |
217 | //completing a previously closed transfer | 217 | //completing a previously closed transfer |
218 | if ( (messageCount - lastSync) <= 0) { | 218 | if ( (messageCount - lastSync) <= 0) { |
219 | temp.setNum(messageCount); | 219 | temp.setNum(messageCount); |
220 | emit updateStatus(tr("Previous message ") + temp); | 220 | emit updateStatus(tr("Previous message ") + temp); |
221 | } else { | 221 | } else { |
222 | emit updateStatus(tr("Completing message ") + temp); | 222 | emit updateStatus(tr("Completing message ") + temp); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | break; | 225 | break; |
226 | } else { | 226 | } else { |
227 | emit updateStatus(tr("No new Messages")); | 227 | emit updateStatus(tr("No new Messages")); |
228 | status = Quit; | 228 | status = Quit; |
229 | } | 229 | } |
230 | } | 230 | } |
231 | //get size of message, eg "500 characters in message.." -> int 500 | 231 | //get size of message, eg "500 characters in message.." -> int 500 |
232 | case Size: { | 232 | case Size: { |
233 | if (status != Quit) { //because of idiotic switch | 233 | if (status != Quit) { //because of idiotic switch |
234 | if (response[0] == '+') { | 234 | if (response[0] == '+') { |
235 | temp = response.replace(0, 4, ""); | 235 | temp = response.replace(0, 4, ""); |
236 | int x = temp.find(" ", 0); | 236 | int x = temp.find(" ", 0); |
237 | temp = temp.right(temp.length() - ((uint) x + 1) ); | 237 | temp = temp.right(temp.length() - ((uint) x + 1) ); |
238 | mailSize = temp.toInt(); | 238 | mailSize = temp.toInt(); |
239 | emit currentMailSize(mailSize); | 239 | emit currentMailSize(mailSize); |
240 | 240 | ||
241 | status = Retr; | 241 | status = Retr; |
242 | } else { | 242 | } else { |
243 | qWarning(response); | 243 | //qWarning(response); |
244 | errorHandling(ErrUnknownResponse); | 244 | errorHandling(ErrUnknownResponse); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
248 | //Read message number x, count upwards to messageCount | 248 | //Read message number x, count upwards to messageCount |
249 | case Retr: { | 249 | case Retr: { |
250 | if (status != Quit) { | 250 | if (status != Quit) { |
251 | if (!preview || mailSize <= headerLimit) { | 251 | if (!preview || mailSize <= headerLimit) { |
252 | *stream << "RETR " << messageCount << "\r\n"; | 252 | *stream << "RETR " << messageCount << "\r\n"; |
253 | } else { //only header | 253 | } else { //only header |
254 | *stream << "TOP " << messageCount << " 0\r\n"; | 254 | *stream << "TOP " << messageCount << " 0\r\n"; |
255 | } | 255 | } |
256 | messageCount++; | 256 | messageCount++; |
257 | status = Ignore; | 257 | status = Ignore; |
258 | break; | 258 | break; |
259 | } } | 259 | } } |
260 | case Ignore: { | 260 | case Ignore: { |
261 | if (status != Quit) { //because of idiotic switch | 261 | if (status != Quit) { //because of idiotic switch |
262 | if (response[0] == '+') { | 262 | if (response[0] == '+') { |
263 | message = ""; | 263 | message = ""; |
264 | status = Read; | 264 | status = Read; |
265 | if (!socket->canReadLine()) //sync. problems | 265 | if (!socket->canReadLine()) //sync. problems |
266 | break; | 266 | break; |
267 | response = socket->readLine(); | 267 | response = socket->readLine(); |
268 | } else errorHandling(ErrUnknownResponse); | 268 | } else errorHandling(ErrUnknownResponse); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | //add all incoming lines to body. When size is reached, send | 271 | //add all incoming lines to body. When size is reached, send |
272 | //message, and go back to read new message | 272 | //message, and go back to read new message |
273 | case Read: { | 273 | case Read: { |
274 | if (status != Quit) { //because of idiotic switch | 274 | if (status != Quit) { //because of idiotic switch |
275 | message += response; | 275 | message += response; |
276 | while ( socket->canReadLine() ) { | 276 | while ( socket->canReadLine() ) { |
277 | response = socket->readLine(); | 277 | response = socket->readLine(); |
278 | message += response; | 278 | message += response; |
279 | } | 279 | } |
280 | emit downloadedSize(message.length()); | 280 | emit downloadedSize(message.length()); |
281 | int x = message.find("\r\n.\r\n",-5); | 281 | int x = message.find("\r\n.\r\n",-5); |
282 | if (x == -1) { | 282 | if (x == -1) { |
283 | break; | 283 | break; |
284 | } else { //message reach entire size | 284 | } else { //message reach entire size |
285 | //complete mail downloaded | 285 | //complete mail downloaded |
286 | if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ | 286 | if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ |
287 | emit newMessage(message, messageCount-1, mailSize, TRUE); | 287 | emit newMessage(message, messageCount-1, mailSize, TRUE); |
288 | } else { //incomplete mail downloaded | 288 | } else { //incomplete mail downloaded |
289 | emit newMessage(message, messageCount-1, mailSize, FALSE); | 289 | emit newMessage(message, messageCount-1, mailSize, FALSE); |
290 | } | 290 | } |
291 | if (messageCount > newMessages) //that was the last message | 291 | if (messageCount > newMessages) //that was the last message |
292 | status = Quit; | 292 | status = Quit; |
293 | else { //ask for new message | 293 | else { //ask for new message |
294 | if (selected) { //grab next from queue | 294 | if (selected) { //grab next from queue |
295 | int *ptr = mailList->next(); | 295 | int *ptr = mailList->next(); |
296 | if (ptr != 0) { | 296 | if (ptr != 0) { |
297 | messageCount = *ptr; | 297 | messageCount = *ptr; |
298 | *stream << "LIST " << messageCount << "\r\n"; | 298 | *stream << "LIST " << messageCount << "\r\n"; |
299 | status = Size; | 299 | status = Size; |
300 | //completing a previously closed transfer | 300 | //completing a previously closed transfer |
301 | if ( (messageCount - lastSync) <= 0) { | 301 | if ( (messageCount - lastSync) <= 0) { |
302 | temp.setNum(messageCount); | 302 | temp.setNum(messageCount); |
303 | emit updateStatus(tr("Previous message ") + temp); | 303 | emit updateStatus(tr("Previous message ") + temp); |
304 | } else { | 304 | } else { |
305 | temp.setNum(messageCount - lastSync); | 305 | temp.setNum(messageCount - lastSync); |
306 | emit updateStatus(tr("Completing message ") + temp); | 306 | emit updateStatus(tr("Completing message ") + temp); |
307 | } | 307 | } |
308 | break; | 308 | break; |
309 | } else { | 309 | } else { |
310 | newMessages--; | 310 | newMessages--; |
311 | status = Quit; | 311 | status = Quit; |
312 | } | 312 | } |
313 | } else { | 313 | } else { |
314 | *stream << "LIST " << messageCount << "\r\n"; | 314 | *stream << "LIST " << messageCount << "\r\n"; |
315 | status = Size; | 315 | status = Size; |
316 | temp2.setNum(newMessages - lastSync); | 316 | temp2.setNum(newMessages - lastSync); |
317 | temp.setNum(messageCount - lastSync); | 317 | temp.setNum(messageCount - lastSync); |
318 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); | 318 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
319 | 319 | ||
320 | break; | 320 | break; |
321 | } | 321 | } |
322 | } | 322 | } |
323 | } | 323 | } |
324 | if (status != Quit) | 324 | if (status != Quit) |
325 | break; | 325 | break; |
326 | } | 326 | } |
327 | } | 327 | } |
328 | case Quit: { | 328 | case Quit: { |
329 | *stream << "Quit\r\n"; | 329 | *stream << "Quit\r\n"; |
330 | status = Done; | 330 | status = Done; |
331 | int newM = newMessages - lastSync; | 331 | int newM = newMessages - lastSync; |
332 | if (newM > 0) { | 332 | if (newM > 0) { |
333 | temp.setNum(newM); | 333 | temp.setNum(newM); |
334 | emit updateStatus(temp + tr(" new messages")); | 334 | emit updateStatus(temp + tr(" new messages")); |
335 | } else { | 335 | } else { |
336 | emit updateStatus(tr("No new messages")); | 336 | emit updateStatus(tr("No new messages")); |
337 | } | 337 | } |
338 | 338 | ||
339 | socket->close(); | 339 | socket->close(); |
340 | receiving = FALSE; | 340 | receiving = FALSE; |
341 | emit mailTransfered(newM); | 341 | emit mailTransfered(newM); |
342 | break; | 342 | break; |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | } | 346 | } |
347 | 347 | ||
348 | // if( bAPOPAuthentication ) | 348 | // if( bAPOPAuthentication ) |
349 | // { | 349 | // { |
350 | // if( m_strTimeStamp.IsEmpty() ) | 350 | // if( m_strTimeStamp.IsEmpty() ) |
351 | // { | 351 | // { |
352 | // SetLastError("Apop error!"); | 352 | // SetLastError("Apop error!"); |
353 | // return false; | 353 | // return false; |
354 | // } | 354 | // } |
355 | // strMD5Source = m_strTimeStamp+pszPassword; | 355 | // strMD5Source = m_strTimeStamp+pszPassword; |
356 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); | 356 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); |
357 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); | 357 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); |
358 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); | 358 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); |
359 | // if(ret == SOCKET_ERROR) | 359 | // if(ret == SOCKET_ERROR) |
360 | // { | 360 | // { |
361 | // SetLastError("Socket error!"); | 361 | // SetLastError("Socket error!"); |
362 | // m_bSocketOK = false; | 362 | // m_bSocketOK = false; |
363 | // m_bConnected = false; | 363 | // m_bConnected = false; |
364 | // return false; | 364 | // return false; |
365 | // } | 365 | // } |
366 | // if( !GetSocketResult(&strResult , COMMAND_END_FLAG) ) | 366 | // if( !GetSocketResult(&strResult , COMMAND_END_FLAG) ) |
367 | // return false; | 367 | // return false; |
368 | // if( 0 == strResult.Find('-' , 0) ) | 368 | // if( 0 == strResult.Find('-' , 0) ) |
369 | // { | 369 | // { |
370 | // SetLastError("Username or Password error!"); | 370 | // SetLastError("Username or Password error!"); |
371 | // return false; | 371 | // return false; |
372 | // } | 372 | // } |
373 | // m_bConnected = true; | 373 | // m_bConnected = true; |
374 | 374 | ||
375 | // } | 375 | // } |
diff --git a/noncore/unsupported/mailit/readmail.cpp b/noncore/unsupported/mailit/readmail.cpp index a5e7147..7cd3e09 100644 --- a/noncore/unsupported/mailit/readmail.cpp +++ b/noncore/unsupported/mailit/readmail.cpp | |||
@@ -1,187 +1,188 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "readmail.h" | 20 | #include "readmail.h" |
21 | #include <qimage.h> | 21 | #include <qimage.h> |
22 | #include <qmime.h> | 22 | #include <qmime.h> |
23 | #include <qaction.h> | 23 | #include <qaction.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) | 26 | ReadMail::ReadMail( QWidget* parent, const char* name, WFlags fl ) |
27 | : QMainWindow(parent, name, fl) | 27 | : QMainWindow(parent, name, fl) |
28 | { | 28 | { |
29 | plainTxt = FALSE; | 29 | plainTxt = FALSE; |
30 | 30 | ||
31 | init(); | 31 | init(); |
32 | viewAtt = new ViewAtt(0, "View Attatchments"); | 32 | viewAtt = new ViewAtt(0, "View Attatchments"); |
33 | } | 33 | } |
34 | 34 | ||
35 | ReadMail::~ReadMail() | 35 | ReadMail::~ReadMail() |
36 | { | 36 | { |
37 | delete emailView->mimeSourceFactory(); | 37 | delete emailView->mimeSourceFactory(); |
38 | delete viewAtt; | 38 | delete viewAtt; |
39 | } | 39 | } |
40 | 40 | ||
41 | void ReadMail::init() | 41 | void ReadMail::init() |
42 | { | 42 | { |
43 | setToolBarsMovable(FALSE); | 43 | setToolBarsMovable(FALSE); |
44 | 44 | ||
45 | bar = new QToolBar(this); | 45 | bar = new QToolBar(this); |
46 | bar->setHorizontalStretchable( TRUE ); | 46 | bar->setHorizontalStretchable( TRUE ); |
47 | 47 | ||
48 | menu = new QMenuBar( bar ); | 48 | menu = new QMenuBar( bar ); |
49 | 49 | ||
50 | viewMenu = new QPopupMenu(menu); | 50 | viewMenu = new QPopupMenu(menu); |
51 | menu->insertItem( tr( "&View" ), viewMenu); | 51 | menu->insertItem( tr( "&View" ), viewMenu); |
52 | 52 | ||
53 | mailMenu = new QPopupMenu(menu); | 53 | mailMenu = new QPopupMenu(menu); |
54 | menu->insertItem( tr( "&Mail" ), mailMenu); | 54 | menu->insertItem( tr( "&Mail" ), mailMenu); |
55 | 55 | ||
56 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
57 | 57 | ||
58 | //reply dependant on viewing inbox | 58 | //reply dependant on viewing inbox |
59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), | 59 | replyButton = new QAction( tr( "Reply" ), Resource::loadPixmap( "mailit/reply" ), |
60 | QString::null, 0, this, 0 ); | 60 | QString::null, 0, this, 0 ); |
61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); | 61 | connect(replyButton, SIGNAL(activated()), this, SLOT(reply()) ); |
62 | 62 | ||
63 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 63 | previousButton = new QAction( tr( "Previous" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
64 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); | 64 | connect( previousButton, SIGNAL( activated() ), this, SLOT( previous() ) ); |
65 | previousButton->addTo(bar); | 65 | previousButton->addTo(bar); |
66 | previousButton->addTo(viewMenu); | 66 | previousButton->addTo(viewMenu); |
67 | 67 | ||
68 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); | 68 | nextButton = new QAction( tr( "Next" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); |
69 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); | 69 | connect( nextButton, SIGNAL( activated() ), this, SLOT( next() ) ); |
70 | nextButton->addTo(bar); | 70 | nextButton->addTo(bar); |
71 | nextButton->addTo(viewMenu); | 71 | nextButton->addTo(viewMenu); |
72 | 72 | ||
73 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); | 73 | attatchmentsButton = new QAction( tr( "Attatchments" ), Resource::loadPixmap( "mailit/attach" ), QString::null, 0, this, 0 ); |
74 | connect( attatchmentsButton, SIGNAL( activated() ), this, | 74 | connect( attatchmentsButton, SIGNAL( activated() ), this, |
75 | SLOT( viewAttatchments() ) ); | 75 | SLOT( viewAttatchments() ) ); |
76 | attatchmentsButton->addTo(bar); | 76 | attatchmentsButton->addTo(bar); |
77 | attatchmentsButton->addTo(viewMenu); | 77 | attatchmentsButton->addTo(viewMenu); |
78 | 78 | ||
79 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); | 79 | plainTextButton = new QAction( tr( "Text Format" ), Resource::loadPixmap( "DocsIcon" ), QString::null, 0, this, 0, TRUE); |
80 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); | 80 | connect( plainTextButton, SIGNAL( activated() ), this, SLOT( shiftText() ) ); |
81 | plainTextButton->addTo(bar); | 81 | plainTextButton->addTo(bar); |
82 | plainTextButton->addTo(viewMenu); | 82 | plainTextButton->addTo(viewMenu); |
83 | 83 | ||
84 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); | 84 | deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); |
85 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); | 85 | connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); |
86 | deleteButton->addTo(bar); | 86 | deleteButton->addTo(bar); |
87 | deleteButton->addTo(mailMenu); | 87 | deleteButton->addTo(mailMenu); |
88 | 88 | ||
89 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); | 89 | viewMenu->insertItem(Resource::loadPixmap("close"), "Close", this, SLOT(close())); |
90 | 90 | ||
91 | emailView = new QTextView( this, "emailView" ); | 91 | emailView = new QTextView( this, "emailView" ); |
92 | |||
92 | setCentralWidget(emailView); | 93 | setCentralWidget(emailView); |
93 | 94 | ||
94 | mime = new QMimeSourceFactory(); | 95 | mime = new QMimeSourceFactory(); |
95 | emailView->setMimeSourceFactory(mime); | 96 | emailView->setMimeSourceFactory(mime); |
96 | } | 97 | } |
97 | 98 | ||
98 | void ReadMail::updateView() | 99 | void ReadMail::updateView() |
99 | { | 100 | { |
100 | Enclosure *ePtr; | 101 | Enclosure *ePtr; |
101 | QString mailStringSize; | 102 | QString mailStringSize; |
102 | QString text, temp; | 103 | QString text, temp; |
103 | 104 | ||
104 | mail->read = TRUE; //mark as read | 105 | mail->read = TRUE; //mark as read |
105 | inbox = mail->received; | 106 | inbox = mail->received; |
106 | 107 | ||
107 | replyButton->removeFrom(mailMenu); | 108 | replyButton->removeFrom(mailMenu); |
108 | replyButton->removeFrom(bar); | 109 | replyButton->removeFrom(bar); |
109 | 110 | ||
110 | if (inbox == TRUE) { | 111 | if (inbox == TRUE) { |
111 | replyButton->addTo(bar); | 112 | replyButton->addTo(bar); |
112 | replyButton->addTo(mailMenu); | 113 | replyButton->addTo(mailMenu); |
113 | 114 | ||
114 | if (!mail->downloaded) { | 115 | if (!mail->downloaded) { |
115 | //report currently viewed mail so that it will be | 116 | //report currently viewed mail so that it will be |
116 | //placed first in the queue of new mails to download | 117 | //placed first in the queue of new mails to download |
117 | emit viewingMail(mail); | 118 | emit viewingMail(mail); |
118 | 119 | ||
119 | double mailSize = (double) mail->size; | 120 | double mailSize = (double) mail->size; |
120 | if (mailSize < 1024) { | 121 | if (mailSize < 1024) { |
121 | mailStringSize.setNum(mailSize); | 122 | mailStringSize.setNum(mailSize); |
122 | mailStringSize += " Bytes"; | 123 | mailStringSize += " Bytes"; |
123 | } else if (mailSize < 1024*1024) { | 124 | } else if (mailSize < 1024*1024) { |
124 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); | 125 | mailStringSize.setNum( (mailSize / 1024), 'g', 2 ); |
125 | mailStringSize += " Kb"; | 126 | mailStringSize += " Kb"; |
126 | } else { | 127 | } else { |
127 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); | 128 | mailStringSize.setNum( (mailSize / (1024*1024)), 'g', 3); |
128 | mailStringSize += " Mb"; | 129 | mailStringSize += " Mb"; |
129 | } | 130 | } |
130 | } | 131 | } |
131 | } | 132 | } |
132 | 133 | ||
133 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); | 134 | QMimeSourceFactory *mime = emailView->mimeSourceFactory(); |
134 | 135 | ||
135 | if (! plainTxt) { //use RichText, inline pics etc. | 136 | if (! plainTxt) { //use RichText, inline pics etc. |
136 | emailView->setTextFormat(QTextView::RichText); | 137 | emailView->setTextFormat(QTextView::RichText); |
137 | text = "<b><big><center><font color=\"blue\">" + mail->subject | 138 | text = "<b><big><center><font color=\"blue\">" + mail->subject |
138 | +"</font></center></big></b><br>"; | 139 | +"</font></center></big></b><br>"; |
139 | text += "<b>From: </b>" + mail->from + " <i>" + | 140 | text += "<b>From: </b>" + mail->from + " <i>" + |
140 | mail->fromMail + "</i><br>"; | 141 | mail->fromMail + "</i><br>"; |
141 | 142 | ||
142 | text +="<b>To: </b>"; | 143 | text +="<b>To: </b>"; |
143 | for (QStringList::Iterator it = mail->recipients.begin(); | 144 | for (QStringList::Iterator it = mail->recipients.begin(); |
144 | it != mail->recipients.end(); ++it ) { | 145 | it != mail->recipients.end(); ++it ) { |
145 | text += *it + " "; | 146 | text += *it + " "; |
146 | } | 147 | } |
147 | text += "<br>" + mail->date; | 148 | text += "<br>" + mail->date; |
148 | 149 | ||
149 | if (mail->files.count() > 0) { | 150 | if (mail->files.count() > 0) { |
150 | text += "<br><b>Attatchments: </b>"; | 151 | text += "<br><b>Attatchments: </b>"; |
151 | 152 | ||
152 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 153 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
153 | text += ePtr->originalName + " "; | 154 | text += ePtr->originalName + " "; |
154 | } | 155 | } |
155 | text += "<hr><br>" + mail->body; | 156 | text += "<hr><br>" + mail->body; |
156 | 157 | ||
157 | if (inbox) { | 158 | if (inbox) { |
158 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { | 159 | for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { |
159 | 160 | ||
160 | text += "<br><hr><b>Attatchment: </b>" + | 161 | text += "<br><hr><b>Attatchment: </b>" + |
161 | ePtr->originalName + "<hr>"; | 162 | ePtr->originalName + "<hr>"; |
162 | 163 | ||
163 | if (ePtr->contentType == "TEXT") { | 164 | if (ePtr->contentType == "TEXT") { |
164 | QFile f(ePtr->path + ePtr->name); | 165 | QFile f(ePtr->path + ePtr->name); |
165 | 166 | ||
166 | if (f.open(IO_ReadOnly) ) { | 167 | if (f.open(IO_ReadOnly) ) { |
167 | QTextStream t(&f); | 168 | QTextStream t(&f); |
168 | temp = t.read(); | 169 | temp = t.read(); |
169 | text += temp + "<br>"; | 170 | text += temp + "<br>"; |
170 | f.close(); | 171 | f.close(); |
171 | } else { | 172 | } else { |
172 | text += "<b>Could not locate file</b><br>"; | 173 | text += "<b>Could not locate file</b><br>"; |
173 | } | 174 | } |
174 | 175 | ||
175 | } | 176 | } |
176 | if (ePtr->contentType == "IMAGE") { | 177 | if (ePtr->contentType == "IMAGE") { |
177 | // temp.setNum(emailView->width());//get display width | 178 | // temp.setNum(emailView->width());//get display width |
178 | // text += "<img width=" + temp +" src =""" + | 179 | // text += "<img width=" + temp +" src =""" + |
179 | // ePtr->originalName + """> </img>"; | 180 | // ePtr->originalName + """> </img>"; |
180 | text += "<img src =""" + | 181 | text += "<img src =""" + |
181 | ePtr->originalName + """> </img>"; | 182 | ePtr->originalName + """> </img>"; |
182 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); | 183 | mime->setPixmap(ePtr->originalName, QPixmap( (ePtr->path + ePtr->name) )); |
183 | } | 184 | } |
184 | } | 185 | } |
185 | } | 186 | } |
186 | } else { | 187 | } else { |
187 | if (mail->downloaded || !inbox) { | 188 | if (mail->downloaded || !inbox) { |
diff --git a/noncore/unsupported/mailit/smtpclient.cpp b/noncore/unsupported/mailit/smtpclient.cpp index 6699a90..b2e38e5 100644 --- a/noncore/unsupported/mailit/smtpclient.cpp +++ b/noncore/unsupported/mailit/smtpclient.cpp | |||
@@ -1,171 +1,171 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "smtpclient.h" | 20 | #include "smtpclient.h" |
21 | #include "emailhandler.h" | 21 | #include "emailhandler.h" |
22 | 22 | ||
23 | SmtpClient::SmtpClient() | 23 | SmtpClient::SmtpClient() |
24 | { | 24 | { |
25 | socket = new QSocket(this, "smtpClient"); | 25 | socket = new QSocket(this, "smtpClient"); |
26 | stream = new QTextStream(socket); | 26 | stream = new QTextStream(socket); |
27 | mailList.setAutoDelete(TRUE); | 27 | mailList.setAutoDelete(TRUE); |
28 | 28 | ||
29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); | 29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); |
30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); | 30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); |
31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); | 31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); |
32 | 32 | ||
33 | sending = FALSE; | 33 | sending = FALSE; |
34 | } | 34 | } |
35 | 35 | ||
36 | SmtpClient::~SmtpClient() | 36 | SmtpClient::~SmtpClient() |
37 | { | 37 | { |
38 | delete socket; | 38 | delete socket; |
39 | delete stream; | 39 | delete stream; |
40 | } | 40 | } |
41 | 41 | ||
42 | void SmtpClient::newConnection(QString target, int port) | 42 | void SmtpClient::newConnection(QString target, int port) |
43 | { | 43 | { |
44 | if (sending) { | 44 | if (sending) { |
45 | qWarning("socket in use, connection refused"); | 45 | qWarning("socket in use, connection refused"); |
46 | return; | 46 | return; |
47 | } | 47 | } |
48 | 48 | ||
49 | status = Init; | 49 | status = Init; |
50 | sending = TRUE; | 50 | sending = TRUE; |
51 | socket->connectToHost(target, port); | 51 | socket->connectToHost(target, port); |
52 | 52 | ||
53 | emit updateStatus(tr("DNS lookup")); | 53 | emit updateStatus(tr("DNS lookup")); |
54 | } | 54 | } |
55 | 55 | ||
56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) | 56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) |
57 | { | 57 | { |
58 | RawEmail *mail = new RawEmail; | 58 | RawEmail *mail = new RawEmail; |
59 | 59 | ||
60 | mail->from = from; | 60 | mail->from = from; |
61 | mail->subject = subject; | 61 | mail->subject = subject; |
62 | mail->to = to; | 62 | mail->to = to; |
63 | mail->body = body; | 63 | mail->body = body; |
64 | 64 | ||
65 | mailList.append(mail); | 65 | mailList.append(mail); |
66 | } | 66 | } |
67 | 67 | ||
68 | void SmtpClient::connectionEstablished() | 68 | void SmtpClient::connectionEstablished() |
69 | { | 69 | { |
70 | emit updateStatus(tr("Connection established")); | 70 | emit updateStatus(tr("Connection established")); |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | void SmtpClient::errorHandling(int status) | 74 | void SmtpClient::errorHandling(int status) |
75 | { | 75 | { |
76 | emit errorOccurred(status); | 76 | emit errorOccurred(status); |
77 | socket->close(); | 77 | socket->close(); |
78 | mailList.clear(); | 78 | mailList.clear(); |
79 | sending = FALSE; | 79 | sending = FALSE; |
80 | } | 80 | } |
81 | 81 | ||
82 | void SmtpClient::incomingData() | 82 | void SmtpClient::incomingData() |
83 | { | 83 | { |
84 | QString response; | 84 | QString response; |
85 | 85 | ||
86 | if (!socket->canReadLine()) | 86 | if (!socket->canReadLine()) |
87 | return; | 87 | return; |
88 | 88 | ||
89 | response = socket->readLine(); | 89 | response = socket->readLine(); |
90 | qDebug(response); | 90 | //qDebug(response); |
91 | 91 | ||
92 | switch(status) { | 92 | switch(status) { |
93 | case Init: { | 93 | case Init: { |
94 | if (response[0] == '2') { | 94 | if (response[0] == '2') { |
95 | status = From; | 95 | status = From; |
96 | mailPtr = mailList.first(); | 96 | mailPtr = mailList.first(); |
97 | *stream << "HELO there\r\n"; | 97 | *stream << "HELO there\r\n"; |
98 | qDebug("HELO"); | 98 | //qDebug("HELO"); |
99 | } else errorHandling(ErrUnknownResponse); | 99 | } else errorHandling(ErrUnknownResponse); |
100 | break; | 100 | break; |
101 | } | 101 | } |
102 | case From: { | 102 | case From: { |
103 | if (response[0] == '2') { | 103 | if (response[0] == '2') { |
104 | *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n"; | 104 | *stream << "MAIL FROM: " << mailPtr->from << "\r\n"; |
105 | status = Recv; | 105 | status = Recv; |
106 | qDebug("MAIL FROM: "+mailPtr->from); | 106 | //qDebug("MAIL FROM: "+mailPtr->from); |
107 | } else errorHandling(ErrUnknownResponse); | 107 | } else errorHandling(ErrUnknownResponse); |
108 | break; | 108 | break; |
109 | } | 109 | } |
110 | case Recv: { | 110 | case Recv: { |
111 | if (response[0] == '2') { | 111 | if (response[0] == '2') { |
112 | it = mailPtr->to.begin(); | 112 | it = mailPtr->to.begin(); |
113 | if (it == NULL) | 113 | if (it == NULL) |
114 | errorHandling(ErrUnknownResponse); | 114 | errorHandling(ErrUnknownResponse); |
115 | *stream << "RCPT TO: <" << *it << ">\r\n"; | 115 | *stream << "RCPT TO: " << *it << ">\r\n"; |
116 | qDebug("RCPT TO: "+ *it); | 116 | //qDebug("RCPT TO: "+ *it); |
117 | status = MRcv; | 117 | status = MRcv; |
118 | } else errorHandling(ErrUnknownResponse); | 118 | } else errorHandling(ErrUnknownResponse); |
119 | break; | 119 | break; |
120 | } | 120 | } |
121 | case MRcv: { | 121 | case MRcv: { |
122 | if (response[0] == '2') { | 122 | if (response[0] == '2') { |
123 | it++; | 123 | it++; |
124 | if ( it != mailPtr->to.end() ) { | 124 | if ( it != mailPtr->to.end() ) { |
125 | *stream << "RCPT TO: <" << *it << ">\r\n"; | 125 | *stream << "RCPT TO: <" << *it << ">\r\n"; |
126 | qDebug("RCPT TO: "+ *it); | 126 | //qDebug("RCPT TO: "+ *it); |
127 | break; | 127 | break; |
128 | } else { | 128 | } else { |
129 | status = Data; | 129 | status = Data; |
130 | } | 130 | } |
131 | } else errorHandling(ErrUnknownResponse); | 131 | } else errorHandling(ErrUnknownResponse); |
132 | } | 132 | } |
133 | case Data: { | 133 | case Data: { |
134 | if (response[0] == '2') { | 134 | if (response[0] == '2') { |
135 | *stream << "DATA\r\n"; | 135 | *stream << "DATA\r\n"; |
136 | status = Body; | 136 | status = Body; |
137 | qDebug("DATA"); | 137 | //qDebug("DATA"); |
138 | emit updateStatus(tr("Sending: ") + mailPtr->subject); | 138 | emit updateStatus(tr("Sending: ") + mailPtr->subject); |
139 | } else errorHandling(ErrUnknownResponse); | 139 | } else errorHandling(ErrUnknownResponse); |
140 | break; | 140 | break; |
141 | } | 141 | } |
142 | case Body: { | 142 | case Body: { |
143 | if (response[0] == '3') { | 143 | if (response[0] == '3') { |
144 | *stream << mailPtr->body << "\r\n.\r\n"; | 144 | *stream << mailPtr->body << "\r\n.\r\n"; |
145 | mailPtr = mailList.next(); | 145 | mailPtr = mailList.next(); |
146 | if (mailPtr != NULL) { | 146 | if (mailPtr != NULL) { |
147 | status = From; | 147 | status = From; |
148 | } else { | 148 | } else { |
149 | status = Quit; | 149 | status = Quit; |
150 | } | 150 | } |
151 | qDebug("BODY"); | 151 | //qDebug("BODY"); |
152 | } else errorHandling(ErrUnknownResponse); | 152 | } else errorHandling(ErrUnknownResponse); |
153 | break; | 153 | break; |
154 | } | 154 | } |
155 | case Quit: { | 155 | case Quit: { |
156 | if (response[0] == '2') { | 156 | if (response[0] == '2') { |
157 | *stream << "QUIT\r\n"; | 157 | *stream << "QUIT\r\n"; |
158 | status = Done; | 158 | status = Done; |
159 | QString temp; | 159 | QString temp; |
160 | temp.setNum(mailList.count()); | 160 | temp.setNum(mailList.count()); |
161 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); | 161 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); |
162 | emit mailSent(); | 162 | emit mailSent(); |
163 | mailList.clear(); | 163 | mailList.clear(); |
164 | sending = FALSE; | 164 | sending = FALSE; |
165 | socket->close(); | 165 | socket->close(); |
166 | qDebug("QUIT"); | 166 | //qDebug("QUIT"); |
167 | } else errorHandling(ErrUnknownResponse); | 167 | } else errorHandling(ErrUnknownResponse); |
168 | break; | 168 | break; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | } | 171 | } |