Example #1
0
void addCommunications(MobilePhone* mobilePhone)
{
    Call* call;
    SMS* sms;
    Email* email;
    PhoneNumber* phoneNumber;
    EmailAddress* emailAddress;

    call = new Call(1);
    call->setDuration(QTime(0, 1, 0));
    call->setDate(QDate::currentDate());
    call->setStatus(AbstractCommunication::DIALLED_STATUS);
    call->setIncoming(true);
    phoneNumber = mobilePhone->getAddressBook().findPhoneNumber("0000000000");

    if(phoneNumber != NULL)
	call->addPhoneNumber(phoneNumber);

    mobilePhone->getCommunicationManager().addCommunication(call);

    sms = new SMS(2);
    sms->setContent("Hello SMS !!");
    sms->setDate(QDate::currentDate());
    sms->setStatus(AbstractCommunication::SENT_STATUS);
    sms->setIncoming(false);
    sms->addPhoneNumber(new PhoneNumber("0000000001"));
    mobilePhone->getCommunicationManager().addCommunication(sms);

    email = new Email(3);
    email->setSubject("Super Hello");
    email->setBody("Hello Email !!");
    email->setDate(QDate::currentDate());
    email->setStatus(AbstractCommunication::RECEIVED_STATUS);
    email->setIncoming(true);
    emailAddress = mobilePhone->getAddressBook().findEmailAddress("*****@*****.**");

    if(emailAddress != NULL)
	email->addInFromList(emailAddress);

    email->addInCCList(new EmailAddress("*****@*****.**"));
    email->addInCCIList(new EmailAddress("*****@*****.**"));
    email->addInToList(new EmailAddress("*****@*****.**"));

    mobilePhone->getCommunicationManager().addCommunication(email);
}