summaryrefslogtreecommitdiff
path: root/protocols/YAMN/src/mails/mails.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-12-12 21:11:44 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-12-12 21:11:44 +0300
commit46793bcdf9bdc0c48a509aa1a2d41dbc262500bf (patch)
treee0a2f1824c50a2ee0a0b9b4de82867db43e67f85 /protocols/YAMN/src/mails/mails.cpp
parentf72215dbc4afeaf81fad333eb6de01591637021b (diff)
YAMN: code cleaning
Diffstat (limited to 'protocols/YAMN/src/mails/mails.cpp')
-rw-r--r--protocols/YAMN/src/mails/mails.cpp399
1 files changed, 189 insertions, 210 deletions
diff --git a/protocols/YAMN/src/mails/mails.cpp b/protocols/YAMN/src/mails/mails.cpp
index d0dbba76ab..168c6c9397 100644
--- a/protocols/YAMN/src/mails/mails.cpp
+++ b/protocols/YAMN/src/mails/mails.cpp
@@ -6,32 +6,32 @@
#include "../stdafx.h"
-//--------------------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------------------------------
-// SMALL INTRO
-// Mails are queued in a queue (chained list). Pointer to first mail is pointed from Account structure
-// member called Mails.
-// Mail queue is ended with NULL- pointered mail (NULL handle)
+ // SMALL INTRO
+ // Mails are queued in a queue (chained list). Pointer to first mail is pointed from Account structure
+ // member called Mails.
+ // Mail queue is ended with NULL- pointered mail (NULL handle)
-//Creates new mail for plugin (calling plugin's constructor, when plugin imported to YAMN)
-INT_PTR CreateAccountMailSvc(WPARAM wParam,LPARAM lParam);
+ //Creates new mail for plugin (calling plugin's constructor, when plugin imported to YAMN)
+INT_PTR CreateAccountMailSvc(WPARAM wParam, LPARAM lParam);
//Deletes mail for plugin (calling plugin's destructor, when plugin imported to YAMN)
-INT_PTR DeleteAccountMailSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR DeleteAccountMailSvc(WPARAM wParam, LPARAM lParam);
//Loads mail data from standard storage to memory
-INT_PTR LoadMailDataSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR LoadMailDataSvc(WPARAM wParam, LPARAM lParam);
//Deletes mail data from memory
-INT_PTR UnloadMailDataSvc(WPARAM wParam,LPARAM);
+INT_PTR UnloadMailDataSvc(WPARAM wParam, LPARAM);
//Saves mail data from memory to standard storage
-INT_PTR SaveMailDataSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR SaveMailDataSvc(WPARAM wParam, LPARAM lParam);
//Appends second MIME mail queue to the first one
//Only finds the end of first queue and its Next memember repoints to second one
-void WINAPI AppendQueueFcn(HYAMNMAIL first,HYAMNMAIL second);
+void WINAPI AppendQueueFcn(HYAMNMAIL first, HYAMNMAIL second);
//Synchronizes two accounts
//Function finds, if there were some mails deleted from mailbox and deletes (depends on RemovedOld param) them from OldQueue
@@ -50,31 +50,31 @@ void WINAPI AppendQueueFcn(HYAMNMAIL first,HYAMNMAIL second);
//So function works like:
//1. delete (or move to RemovedOld queue if RemovedOld is not NULL) all mails from OldQueue not found in NewQueue
//2. delete (or move to RemovedNew queue if RemovedNew is not NULL) all mails from NewQueue found in OldQueue
-void WINAPI SynchroMessagesFcn(CAccount *Account,HYAMNMAIL *OldQueue,HYAMNMAIL *RemovedOld,HYAMNMAIL *NewQueue,HYAMNMAIL *RemovedNew);
+void WINAPI SynchroMessagesFcn(CAccount *Account, HYAMNMAIL *OldQueue, HYAMNMAIL *RemovedOld, HYAMNMAIL *NewQueue, HYAMNMAIL *RemovedNew);
//Deletes messages from mail From to the end
// Account- account who owns mails
// From- first mail in queue, which is going to delete
-void WINAPI DeleteMessagesToEndFcn(CAccount *Account,HYAMNMAIL From);
+void WINAPI DeleteMessagesToEndFcn(CAccount *Account, HYAMNMAIL From);
//Removes message from queue, does not delete from memory
// From- queue pointer
// Which- mail to delete
// mode- nonzero if you want to decrement numbers in messages that are bigger than the one in Which mail, 0 if not
-void WINAPI DeleteMessageFromQueueFcn(HYAMNMAIL *From,HYAMNMAIL Which,int mode);
+void WINAPI DeleteMessageFromQueueFcn(HYAMNMAIL *From, HYAMNMAIL Which, int mode);
//Finds message in queue that has the same ID number
// From- message queue
// ID- pointer to ID
// returns pointer to found message, NULL if not found
-HYAMNMAIL WINAPI FindMessageByIDFcn(HYAMNMAIL From,char *ID);
+HYAMNMAIL WINAPI FindMessageByIDFcn(HYAMNMAIL From, char *ID);
//Translate header from text to queue of CMimeItem structures
//This means that new queue will contain all info about headers
// stream- pointer to text containing header (can be ended with zero)
// len- length of stream
// head- function fills this pointer to first header item in queue
-void WINAPI TranslateHeaderFcn(char *stream,int len,struct CMimeItem **head);
+void WINAPI TranslateHeaderFcn(char *stream, int len, struct CMimeItem **head);
//Creates new mail queue, copying only these mails, that have set flag for deleting
// From- message queue, whose mail with given flag are duplicated
@@ -89,69 +89,66 @@ HYAMNMAIL WINAPI CreateNewDeleteQueueFcn(HYAMNMAIL From);
// FlagsNotSet- ...and must not have set these flags...
// FlagsToSetRemove- ...to set/remove these flags (see mode)
// mode- nonzero to set, else remove
-void WINAPI SetRemoveFlagsInQueueFcn(HYAMNMAIL From,uint32_t FlagsSet,uint32_t FlagsNotSet,uint32_t FlagsToSetRemove,int mode);
+void WINAPI SetRemoveFlagsInQueueFcn(HYAMNMAIL From, uint32_t FlagsSet, uint32_t FlagsNotSet, uint32_t FlagsToSetRemove, int mode);
-struct CExportedFunctions MailExportedFcn[]=
+struct CExportedFunctions MailExportedFcn[] =
{
- {YAMN_SYNCHROMIMEMSGSID,(void *)SynchroMessagesFcn},
- {YAMN_TRANSLATEHEADERID,(void *)TranslateHeaderFcn},
- {YAMN_APPENDQUEUEID,(void *)AppendQueueFcn},
- {YAMN_DELETEMIMEQUEUEID,(void *)DeleteMessagesToEndFcn},
- {YAMN_DELETEMIMEMESSAGEID,(void *)DeleteMessageFromQueueFcn},
- {YAMN_FINDMIMEMESSAGEID,(void *)FindMessageByIDFcn},
- {YAMN_CREATENEWDELETEQUEUEID,(void *)CreateNewDeleteQueueFcn},
- {YAMN_SETREMOVEQUEUEFLAGSID,(void *)SetRemoveFlagsInQueueFcn},
+ {YAMN_SYNCHROMIMEMSGSID, (void *)SynchroMessagesFcn},
+ {YAMN_TRANSLATEHEADERID, (void *)TranslateHeaderFcn},
+ {YAMN_APPENDQUEUEID, (void *)AppendQueueFcn},
+ {YAMN_DELETEMIMEQUEUEID, (void *)DeleteMessagesToEndFcn},
+ {YAMN_DELETEMIMEMESSAGEID, (void *)DeleteMessageFromQueueFcn},
+ {YAMN_FINDMIMEMESSAGEID, (void *)FindMessageByIDFcn},
+ {YAMN_CREATENEWDELETEQUEUEID, (void *)CreateNewDeleteQueueFcn},
+ {YAMN_SETREMOVEQUEUEFLAGSID, (void *)SetRemoveFlagsInQueueFcn},
};
-struct CExportedServices MailExportedSvc[]=
+struct CExportedServices MailExportedSvc[] =
{
- {MS_YAMN_CREATEACCOUNTMAIL,CreateAccountMailSvc},
- {MS_YAMN_DELETEACCOUNTMAIL,DeleteAccountMailSvc},
- {MS_YAMN_LOADMAILDATA,LoadMailDataSvc},
- {MS_YAMN_UNLOADMAILDATA,UnloadMailDataSvc},
- {MS_YAMN_SAVEMAILDATA,SaveMailDataSvc},
+ {MS_YAMN_CREATEACCOUNTMAIL, CreateAccountMailSvc},
+ {MS_YAMN_DELETEACCOUNTMAIL, DeleteAccountMailSvc},
+ {MS_YAMN_LOADMAILDATA, LoadMailDataSvc},
+ {MS_YAMN_UNLOADMAILDATA, UnloadMailDataSvc},
+ {MS_YAMN_SAVEMAILDATA, SaveMailDataSvc},
};
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
-INT_PTR CreateAccountMailSvc(WPARAM wParam,LPARAM lParam)
+INT_PTR CreateAccountMailSvc(WPARAM wParam, LPARAM lParam)
{
- CAccount *Account=(CAccount *)wParam;
- uint32_t MailVersion=(uint32_t)lParam;
+ CAccount *Account = (CAccount *)wParam;
+ uint32_t MailVersion = (uint32_t)lParam;
HYAMNMAIL NewMail;
-//test if we are going to initialize members of suitable structure (structures of plugin and YAMN must match)
+ //test if we are going to initialize members of suitable structure (structures of plugin and YAMN must match)
if (MailVersion != YAMN_MAILVERSION)
return NULL;
- if (Account->Plugin != nullptr)
- {
- if (Account->Plugin->MailFcn->NewMailFcnPtr != nullptr)
- {
-//Let plugin create its own structure, which can be derived from CAccount structure
- if (nullptr==(NewMail=Account->Plugin->MailFcn->NewMailFcnPtr(Account,YAMN_MAILVERSION)))
+ if (Account->Plugin != nullptr) {
+ if (Account->Plugin->MailFcn->NewMailFcnPtr != nullptr) {
+ //Let plugin create its own structure, which can be derived from CAccount structure
+ if (nullptr == (NewMail = Account->Plugin->MailFcn->NewMailFcnPtr(Account, YAMN_MAILVERSION)))
return NULL;
}
- else
- {
-//We suggest plugin uses standard CAccount structure, so we create it
- if (nullptr==(NewMail=new YAMNMAIL))
-//If not created successfully
+ else {
+ //We suggest plugin uses standard CAccount structure, so we create it
+ if (nullptr == (NewMail = new YAMNMAIL))
+ //If not created successfully
return NULL;
- NewMail->MailData=nullptr;
+ NewMail->MailData = nullptr;
}
-//Init every members of structure, used by YAMN
+ //Init every members of structure, used by YAMN
return (INT_PTR)NewMail;
}
return NULL;
}
-INT_PTR DeleteAccountMailSvc(WPARAM wParam,LPARAM lParam)
+INT_PTR DeleteAccountMailSvc(WPARAM wParam, LPARAM lParam)
{
- HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
- HYAMNMAIL OldMail=(HYAMNMAIL)lParam;
+ HYAMNPROTOPLUGIN Plugin = (HYAMNPROTOPLUGIN)wParam;
+ HYAMNMAIL OldMail = (HYAMNMAIL)lParam;
struct CMimeItem *TH;
if (Plugin->MailFcn != nullptr) {
@@ -164,15 +161,15 @@ INT_PTR DeleteAccountMailSvc(WPARAM wParam,LPARAM lParam)
if (OldMail->MailData != nullptr) {
if (OldMail->MailData->Body != nullptr)
delete[] OldMail->MailData->Body;
- if ((TH=OldMail->MailData->TranslatedHeader) != nullptr)
- for (;OldMail->MailData->TranslatedHeader != nullptr;) {
- TH=TH->Next;
+ if ((TH = OldMail->MailData->TranslatedHeader) != nullptr)
+ for (; OldMail->MailData->TranslatedHeader != nullptr;) {
+ TH = TH->Next;
if (OldMail->MailData->TranslatedHeader->name != nullptr)
delete[] OldMail->MailData->TranslatedHeader->name;
if (OldMail->MailData->TranslatedHeader->value != nullptr)
delete[] OldMail->MailData->TranslatedHeader->value;
delete OldMail->MailData->TranslatedHeader;
- OldMail->MailData->TranslatedHeader=TH;
+ OldMail->MailData->TranslatedHeader = TH;
}
delete OldMail->MailData;
}
@@ -184,17 +181,17 @@ INT_PTR DeleteAccountMailSvc(WPARAM wParam,LPARAM lParam)
}
-void WINAPI AppendQueueFcn(HYAMNMAIL first,HYAMNMAIL second)
+void WINAPI AppendQueueFcn(HYAMNMAIL first, HYAMNMAIL second)
{
- HYAMNMAIL Finder=first;
- while(Finder->Next != nullptr) Finder=Finder->Next;
- Finder->Next=second;
+ HYAMNMAIL Finder = first;
+ while (Finder->Next != nullptr) Finder = Finder->Next;
+ Finder->Next = second;
}
-INT_PTR LoadMailDataSvc(WPARAM wParam,LPARAM lParam)
+INT_PTR LoadMailDataSvc(WPARAM wParam, LPARAM lParam)
{
- HYAMNMAIL Mail=(HYAMNMAIL)wParam;
- uint32_t MailVersion=(uint32_t)lParam;
+ HYAMNMAIL Mail = (HYAMNMAIL)wParam;
+ uint32_t MailVersion = (uint32_t)lParam;
if (MailVersion != YAMN_MAILDATAVERSION)
return NULL;
@@ -210,7 +207,7 @@ INT_PTR UnloadMailDataSvc(WPARAM, LPARAM)
INT_PTR SaveMailDataSvc(WPARAM, LPARAM lParam)
{
- uint32_t MailVersion=(uint32_t)lParam;
+ uint32_t MailVersion = (uint32_t)lParam;
if (MailVersion != YAMN_MAILDATAVERSION)
return (INT_PTR)-1;
@@ -219,203 +216,192 @@ INT_PTR SaveMailDataSvc(WPARAM, LPARAM lParam)
return (INT_PTR)0;
}
-void WINAPI SynchroMessagesFcn(CAccount *Account,HYAMNMAIL *OldQueue,HYAMNMAIL *RemovedOld,HYAMNMAIL *NewQueue,HYAMNMAIL *RemovedNew)
+void WINAPI SynchroMessagesFcn(CAccount *Account, HYAMNMAIL *OldQueue, HYAMNMAIL *RemovedOld, HYAMNMAIL *NewQueue, HYAMNMAIL *RemovedNew)
//deletes messages from new queue, if they are old
//it also deletes messages from old queue, if they are not in mailbox anymore
//"YAMN_MSG_DELETED" messages in old queue remain in old queue (are never removed, although they are not in new queue)
//"YAMN_MSG_DELETED" messages in new queue remain in new queue (are never removed, although they can be in old queue)
{
- HYAMNMAIL Finder,FinderPrev;
- HYAMNMAIL Parser,ParserPrev;
- HYAMNMAIL RemovedOldParser =nullptr;
- HYAMNMAIL RemovedNewParser =nullptr;
- if (RemovedOld != nullptr) *RemovedOld=nullptr;
- if (RemovedNew != nullptr) *RemovedNew=nullptr;
-
- for (FinderPrev=nullptr,Finder=*OldQueue;Finder != nullptr;)
- {
+ HYAMNMAIL Finder, FinderPrev;
+ HYAMNMAIL Parser, ParserPrev;
+ HYAMNMAIL RemovedOldParser = nullptr;
+ HYAMNMAIL RemovedNewParser = nullptr;
+ if (RemovedOld != nullptr) *RemovedOld = nullptr;
+ if (RemovedNew != nullptr) *RemovedNew = nullptr;
+
+ for (FinderPrev = nullptr, Finder = *OldQueue; Finder != nullptr;) {
if (Finder->Flags & YAMN_MSG_DELETED) //if old queue contains deleted mail
{
- FinderPrev=Finder;
- Finder=Finder->Next; //get next message in old queue for testing
+ FinderPrev = Finder;
+ Finder = Finder->Next; //get next message in old queue for testing
continue;
}
- for (ParserPrev=nullptr,Parser=*NewQueue;Parser != nullptr;ParserPrev=Parser,Parser=Parser->Next)
- {
+ for (ParserPrev = nullptr, Parser = *NewQueue; Parser != nullptr; ParserPrev = Parser, Parser = Parser->Next) {
if (Parser->Flags & YAMN_MSG_DELETED)
continue;
- if (Parser->ID==nullptr) //simply ignore the message, that has not filled its ID
+ if (Parser->ID == nullptr) //simply ignore the message, that has not filled its ID
continue;
- if (0==mir_strcmp(Parser->ID,Finder->ID)) //search for equal message in new queue
+ if (0 == mir_strcmp(Parser->ID, Finder->ID)) //search for equal message in new queue
break;
}
if (Parser != nullptr) //found equal message in new queue
{
- if (Parser==*NewQueue)
- *NewQueue=(*NewQueue)->Next;
+ if (Parser == *NewQueue)
+ *NewQueue = (*NewQueue)->Next;
else
- ParserPrev->Next=Parser->Next;
- Finder->Number=Parser->Number; //rewrite the number of current message in old queue
+ ParserPrev->Next = Parser->Next;
+ Finder->Number = Parser->Number; //rewrite the number of current message in old queue
- if (RemovedNew==nullptr) //delete from new queue
- DeleteAccountMailSvc((WPARAM)Account->Plugin,(LPARAM)Parser);
+ if (RemovedNew == nullptr) //delete from new queue
+ DeleteAccountMailSvc((WPARAM)Account->Plugin, (LPARAM)Parser);
else //or move to RemovedNew
{
- if (RemovedNewParser==nullptr) //if it is first mail removed from NewQueue
- *RemovedNew=Parser; //set RemovedNew queue to point to first message in removed queue
+ if (RemovedNewParser == nullptr) //if it is first mail removed from NewQueue
+ *RemovedNew = Parser; //set RemovedNew queue to point to first message in removed queue
else
- RemovedNewParser->Next=Parser; //else don't forget to show to next message in RemovedNew queue
- RemovedNewParser=Parser; //follow RemovedNew queue
- RemovedNewParser->Next=nullptr;
+ RemovedNewParser->Next = Parser; //else don't forget to show to next message in RemovedNew queue
+ RemovedNewParser = Parser; //follow RemovedNew queue
+ RemovedNewParser->Next = nullptr;
}
- FinderPrev=Finder;
- Finder=Finder->Next; //get next message in old queue for testing
+ FinderPrev = Finder;
+ Finder = Finder->Next; //get next message in old queue for testing
}
else //a message was already deleted from mailbox
{
- if (Finder==*OldQueue) //if we are at the first item in OldQueue
+ if (Finder == *OldQueue) //if we are at the first item in OldQueue
{
- *OldQueue=(*OldQueue)->Next; //set OldQueue to next item
- if (RemovedOld==nullptr) //delete from old queue
- DeleteAccountMailSvc((WPARAM)Account->Plugin,(LPARAM)Finder);
+ *OldQueue = (*OldQueue)->Next; //set OldQueue to next item
+ if (RemovedOld == nullptr) //delete from old queue
+ DeleteAccountMailSvc((WPARAM)Account->Plugin, (LPARAM)Finder);
else //or move to RemovedOld
{
- if (RemovedOldParser==nullptr) //if it is first mail removed from OldQueue
- *RemovedOld=Finder; //set RemovedOld queue to point to first message in removed queue
+ if (RemovedOldParser == nullptr) //if it is first mail removed from OldQueue
+ *RemovedOld = Finder; //set RemovedOld queue to point to first message in removed queue
else
- RemovedOldParser->Next=Finder; //else don't forget to show to next message in RemovedNew queue
- RemovedOldParser=Finder; //follow RemovedOld queue
- RemovedOldParser->Next=nullptr;
+ RemovedOldParser->Next = Finder; //else don't forget to show to next message in RemovedNew queue
+ RemovedOldParser = Finder; //follow RemovedOld queue
+ RemovedOldParser->Next = nullptr;
}
- Finder=*OldQueue;
+ Finder = *OldQueue;
}
- else
- {
- FinderPrev->Next=Finder->Next;
- if (RemovedOld==nullptr) //delete from old queue
- DeleteAccountMailSvc((WPARAM)Account->Plugin,(LPARAM)Finder);
+ else {
+ FinderPrev->Next = Finder->Next;
+ if (RemovedOld == nullptr) //delete from old queue
+ DeleteAccountMailSvc((WPARAM)Account->Plugin, (LPARAM)Finder);
else //or move to RemovedOld
{
- if (RemovedOldParser==nullptr) //if it is first mail removed from OldQueue
- *RemovedOld=Finder; //set RemovedOld queue to point to first message in removed queue
+ if (RemovedOldParser == nullptr) //if it is first mail removed from OldQueue
+ *RemovedOld = Finder; //set RemovedOld queue to point to first message in removed queue
else
- RemovedOldParser->Next=Finder; //else don't forget to show to next message in RemovedNew queue
- RemovedOldParser=Finder; //follow RemovedOld queue
- RemovedOldParser->Next=nullptr;
+ RemovedOldParser->Next = Finder; //else don't forget to show to next message in RemovedNew queue
+ RemovedOldParser = Finder; //follow RemovedOld queue
+ RemovedOldParser->Next = nullptr;
}
- Finder=FinderPrev->Next;
+ Finder = FinderPrev->Next;
}
}
}
}
-void WINAPI DeleteMessagesToEndFcn(CAccount *Account,HYAMNMAIL From)
+void WINAPI DeleteMessagesToEndFcn(CAccount *Account, HYAMNMAIL From)
{
HYAMNMAIL Temp;
- while(From != nullptr)
- {
- Temp=From;
- From=From->Next;
- DeleteAccountMailSvc((WPARAM)Account->Plugin,(LPARAM)Temp);
+ while (From != nullptr) {
+ Temp = From;
+ From = From->Next;
+ DeleteAccountMailSvc((WPARAM)Account->Plugin, (LPARAM)Temp);
}
}
-void WINAPI DeleteMessageFromQueueFcn(HYAMNMAIL *From,HYAMNMAIL Which,int mode=0)
+void WINAPI DeleteMessageFromQueueFcn(HYAMNMAIL *From, HYAMNMAIL Which, int mode = 0)
{
- uint32_t Number=Which->Number;
+ uint32_t Number = Which->Number;
HYAMNMAIL Parser;
- if (*From==Which)
- {
- Parser=Which->Next;
- *From=Parser;
+ if (*From == Which) {
+ Parser = Which->Next;
+ *From = Parser;
+ }
+ else {
+ for (Parser = *From; Which != Parser->Next; Parser = Parser->Next)
+ if (mode && (Parser->Number > Number)) Parser->Number--;
+ if (mode && (Parser->Number > Number)) Parser->Number--;
+ Parser->Next = Parser->Next->Next;
+ Parser = Which->Next;
}
- else
- {
- for (Parser=*From;Which != Parser->Next;Parser=Parser->Next)
- if (mode && (Parser->Number>Number)) Parser->Number--;
- if (mode && (Parser->Number>Number)) Parser->Number--;
- Parser->Next=Parser->Next->Next;
- Parser=Which->Next;
- }
if (mode)
- for (;Parser != nullptr;Parser=Parser->Next)
- if (Parser->Number>Number) Parser->Number--;
+ for (; Parser != nullptr; Parser = Parser->Next)
+ if (Parser->Number > Number) Parser->Number--;
}
-void DeleteMessagesFromQueue(HYAMNMAIL *From,HYAMNMAIL Which,int mode=0)
+void DeleteMessagesFromQueue(HYAMNMAIL *From, HYAMNMAIL Which, int mode = 0)
{
HYAMNMAIL Parser;
- for (Parser=Which;Parser != nullptr;Parser=Parser->Next)
- DeleteMessageFromQueueFcn(From,Parser,mode);
+ for (Parser = Which; Parser != nullptr; Parser = Parser->Next)
+ DeleteMessageFromQueueFcn(From, Parser, mode);
}
-HYAMNMAIL WINAPI FindMessageByIDFcn(HYAMNMAIL From,char *ID)
+HYAMNMAIL WINAPI FindMessageByIDFcn(HYAMNMAIL From, char *ID)
{
HYAMNMAIL Browser;
- for (Browser=From;Browser != nullptr;Browser=Browser->Next)
- if (0==mir_strcmp(Browser->ID,ID))
+ for (Browser = From; Browser != nullptr; Browser = Browser->Next)
+ if (0 == mir_strcmp(Browser->ID, ID))
break;
return Browser;
}
-void WINAPI TranslateHeaderFcn(char *stream,int len,struct CMimeItem **head)
+void WINAPI TranslateHeaderFcn(char *stream, int len, struct CMimeItem **head)
{
- try
- {
- char *finder=stream;
- char *prev1,*prev2,*prev3;
- struct CMimeItem *Item=nullptr;
+ try {
+ char *finder = stream;
+ char *prev1, *prev2, *prev3;
+ struct CMimeItem *Item = nullptr;
- while(finder<=(stream+len))
- {
- while(ENDLINEWS(finder)) finder++;
+ while (finder <= (stream + len)) {
+ while (ENDLINEWS(finder)) finder++;
//at the start of line
- if (DOTLINE(finder+1)) //at the end of stream
+ if (DOTLINE(finder + 1)) //at the end of stream
break;
- prev1=finder;
+ prev1 = finder;
- while(*finder != ':' && !EOS(finder)) finder++;
+ while (*finder != ':' && !EOS(finder)) finder++;
if (!EOS(finder))
- prev2=finder++;
+ prev2 = finder++;
else
break;
- while(WS(finder) && !EOS(finder)) finder++;
+ while (WS(finder) && !EOS(finder)) finder++;
if (!EOS(finder))
- prev3=finder;
+ prev3 = finder;
else
break;
- do
- {
- if (ENDLINEWS(finder)) finder+=2; //after endline information continues
- while(!ENDLINE(finder) && !EOS(finder)) finder++;
- }while(ENDLINEWS(finder));
+ do {
+ if (ENDLINEWS(finder)) finder += 2; //after endline information continues
+ while (!ENDLINE(finder) && !EOS(finder)) finder++;
+ } while (ENDLINEWS(finder));
- if (Item != nullptr)
- {
- if (nullptr==(Item->Next=new struct CMimeItem))
+ if (Item != nullptr) {
+ if (nullptr == (Item->Next = new struct CMimeItem))
break;
- Item=Item->Next;
+ Item = Item->Next;
}
- else
- {
+ else {
Item = new CMimeItem;
*head = Item;
}
- Item->Next=nullptr;
- Item->name=new char [prev2-prev1+1];
- mir_strncpy(Item->name,prev1,prev2-prev1+1);
- Item->value=new char [finder-prev3+1];
- mir_strncpy(Item->value,prev3,finder-prev3+1);
+ Item->Next = nullptr;
+ Item->name = new char[prev2 - prev1 + 1];
+ mir_strncpy(Item->name, prev1, prev2 - prev1 + 1);
+ Item->value = new char[finder - prev3 + 1];
+ mir_strncpy(Item->value, prev3, finder - prev3 + 1);
if (EOS(finder))
break;
@@ -427,68 +413,61 @@ void WINAPI TranslateHeaderFcn(char *stream,int len,struct CMimeItem **head)
finder++;
if (ENDLINE(finder))finder++;
prev1 = finder;
- while (!DOTLINE(finder+1))finder++;
+ while (!DOTLINE(finder + 1))finder++;
if (ENDLINE(finder))finder--;
prev2 = finder;
- if (prev2>prev1) { // yes, we have body
- if (nullptr==(Item->Next=new struct CMimeItem)) break; // Cant create new item?!
- Item=Item->Next;
- Item->Next=nullptr;//just in case;
- Item->name=new char[5]; strncpy(Item->name,"Body",5);
- Item->value=new char [prev2-prev1];
- mir_strncpy(Item->value,prev1,prev2-prev1-1);
+ if (prev2 > prev1) { // yes, we have body
+ if (nullptr == (Item->Next = new struct CMimeItem)) break; // Cant create new item?!
+ Item = Item->Next;
+ Item->Next = nullptr;//just in case;
+ Item->name = new char[5]; strncpy(Item->name, "Body", 5);
+ Item->value = new char[prev2 - prev1];
+ mir_strncpy(Item->value, prev1, prev2 - prev1 - 1);
}
break; // there is nothing else
}
}
}
}
- catch(...)
- {
- MessageBoxA(nullptr,"Translate header error","",0);
+ catch (...) {
+ MessageBoxA(nullptr, "Translate header error", "", 0);
}
}
HYAMNMAIL WINAPI CreateNewDeleteQueueFcn(HYAMNMAIL From)
{
- HYAMNMAIL FirstMail,Browser = nullptr;
+ HYAMNMAIL FirstMail, Browser = nullptr;
- for (FirstMail=nullptr;From != nullptr;From=From->Next)
- {
- if ((From->Flags & (YAMN_MSG_USERDELETE | YAMN_MSG_AUTODELETE)) && !(From->Flags & YAMN_MSG_DELETED))
- {
- if (FirstMail==nullptr)
- {
- FirstMail=Browser=new YAMNMAIL;
- if (FirstMail==nullptr)
+ for (FirstMail = nullptr; From != nullptr; From = From->Next) {
+ if ((From->Flags & (YAMN_MSG_USERDELETE | YAMN_MSG_AUTODELETE)) && !(From->Flags & YAMN_MSG_DELETED)) {
+ if (FirstMail == nullptr) {
+ FirstMail = Browser = new YAMNMAIL;
+ if (FirstMail == nullptr)
break;
}
- else
- {
- Browser->Next=new YAMNMAIL;
- Browser=Browser->Next;
+ else {
+ Browser->Next = new YAMNMAIL;
+ Browser = Browser->Next;
}
- Browser->ID=new char[mir_strlen(From->ID)+1];
- mir_strcpy(Browser->ID,From->ID);
- Browser->Number=From->Number;
- Browser->Flags=From->Flags;
+ Browser->ID = new char[mir_strlen(From->ID) + 1];
+ mir_strcpy(Browser->ID, From->ID);
+ Browser->Number = From->Number;
+ Browser->Flags = From->Flags;
}
}
return FirstMail;
}
-void WINAPI SetRemoveFlagsInQueueFcn(HYAMNMAIL From,uint32_t FlagsSet,uint32_t FlagsNotSet,uint32_t FlagsToSetRemove,int mode)
+void WINAPI SetRemoveFlagsInQueueFcn(HYAMNMAIL From, uint32_t FlagsSet, uint32_t FlagsNotSet, uint32_t FlagsToSetRemove, int mode)
{
HYAMNMAIL msgq;
- for (msgq=(HYAMNMAIL)From;msgq != nullptr;msgq=msgq->Next)
- {
- if ((FlagsSet==(msgq->Flags & FlagsSet)) && (0==(msgq->Flags & FlagsNotSet)))
- {
+ for (msgq = (HYAMNMAIL)From; msgq != nullptr; msgq = msgq->Next) {
+ if ((FlagsSet == (msgq->Flags & FlagsSet)) && (0 == (msgq->Flags & FlagsNotSet))) {
if (mode)
- msgq->Flags=msgq->Flags | FlagsToSetRemove;
+ msgq->Flags = msgq->Flags | FlagsToSetRemove;
else
- msgq->Flags=msgq->Flags & ~FlagsToSetRemove;
+ msgq->Flags = msgq->Flags & ~FlagsToSetRemove;
}
}
}