changed getAllMessages to take a parameter, in order to sort incomming and sent messages.
Added a parameter to getIncommingOrSentMessages in order to sort messages.