qalarm_p.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "qalarm_p.h"
  2. #include <ASCliSession.h>
  3. #include <ASShdAlarm.h>
  4. #include <ASShdDefs.h>
  5. // http://www.developer.nokia.com/Community/Wiki/CalInterimAPI
  6. QAlarmPrivate::QAlarmPrivate(QAlarm* aPublicAPI): iPublicAlarm(aPublicAPI)
  7. {
  8. }
  9. QAlarmPrivate::~QAlarmPrivate()
  10. {
  11. delete iPublicAlarm;
  12. }
  13. //int QAlarmPrivate::add(QString message, QAlarm::Type type){
  14. int QAlarmPrivate::add(QString message, int interval){
  15. TPtrC syMessage (static_cast<const TUint16*>(message.utf16()), message.length());
  16. /*TASShdAlarm alarm;
  17. alarm.Category() = KASCliCategoryClock;
  18. alarm.RepeatDefinition() = EAlarmRepeatDefintionRepeatDaily;
  19. TPtrC syMessage (static_cast<const TUint16*>(message.utf16()), message.length());
  20. //_LIT( KAlarmTestInit, "This is an alarm message - alarm 1" );
  21. //alarm.Message() = KAlarmTestInit;
  22. alarm.Message() = syMessage;
  23. alarm.NextDueTime().HomeTime();
  24. alarm.NextDueTime() += TTimeIntervalMinutes( 1 );
  25. /*_LIT( KAlarmTestSoundName, "Arf Arf Woop" );
  26. alarm.SoundName() = KAlarmTestSoundName;*/
  27. /*TInt ret = TheAlarmServerSession.AlarmAdd( alarm );
  28. //TAlarmId alarmId = alarm.Id();
  29. return alarm.Id();*/
  30. RASCliSession iSession; // client interface to alarm server
  31. iSession.Connect();
  32. TASShdAlarm iAlarm; //Alarm object
  33. TTime ihomeTime;
  34. ihomeTime.HomeTime(); // Get Current Hometime(local time set in mobile)
  35. //Tint interval;
  36. // interval – Give seconds after which alarm should expire
  37. TTimeIntervalSeconds intervalSecs(interval);
  38. //Returns the time alarm is scheduled to expire
  39. TTime& iNDT = iAlarm.NextDueTime();
  40. //Set the NextDueTime in which alarm will expire
  41. iNDT = ihomeTime + intervalSecs;
  42. TAlarmMessage& imessage(iAlarm.Message());
  43. //imessage.Copy(_L("Alarm")); //Alarm message
  44. imessage.Copy(syMessage); //Alarm message
  45. iSession.AlarmAdd(iAlarm);
  46. iSession.Close();
  47. }