00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include <asshdalarm.h>
00041 #include <asclisession.h>
00042
00043 #include "alarmserver_symbian.h"
00044
00048 AlarmServerExPrivate* AlarmServerExPrivate::NewL(AlarmServerEx *aPublicAPI)
00049 {
00050 AlarmServerExPrivate* self = new (ELeave) AlarmServerExPrivate(aPublicAPI);
00051 CleanupStack::PushL(self);
00052 self->ConstructL();
00053 CleanupStack::Pop(self);
00054 return self;
00055 }
00056
00060 void AlarmServerExPrivate::ConstructL()
00061 {
00062
00063 User::LeaveIfError(iAlarmServerSession.Connect());
00064 }
00065
00070 AlarmServerExPrivate::AlarmServerExPrivate(AlarmServerEx *aPublicAPI):iPublic(aPublicAPI)
00071 {
00072
00073 }
00074
00075 AlarmServerExPrivate::~AlarmServerExPrivate()
00076 {
00077
00078
00079
00080 iAlarmServerSession.Close();
00081 }
00082
00086 void AlarmServerExPrivate::AddFixedAlarm()
00087 {
00088
00089 TASShdAlarm alarm;
00090
00091
00092 _LIT(KAlarmMessage, "This is a fixed alarm");
00093 alarm.Message() = KAlarmMessage;
00094
00095
00096 _LIT(KAlarmSound, "Chimes");
00097 alarm.SoundName() = KAlarmSound;
00098
00099
00100 alarm.RepeatDefinition() = EAlarmRepeatDefintionRepeatOnce;
00101
00102 TTime time;
00103
00104
00105 time.UniversalTime();
00106
00107
00108 time += TTimeIntervalSeconds(10);
00109 alarm.SetUtcNextDueTime(time);
00110
00111
00112 User::LeaveIfError(iAlarmServerSession.AlarmAdd(alarm));
00113
00114
00115 QString alarmId;
00116 alarmId.setNum(int(alarm.Id()));
00117 emit iPublic->alarmAdded(alarmId);
00118 }
00119
00123 void AlarmServerExPrivate::AddFloatingAlarm()
00124 {
00125
00126 TASShdAlarm alarm;
00127
00128
00129 alarm.RepeatDefinition() = EAlarmRepeatDefintionRepeatOnce;
00130
00131
00132 _LIT(KAlarmMessage,"This is a floating alarm.");
00133 alarm.Message() = KAlarmMessage;
00134
00135
00136 _LIT(KAlarmSound, "Chimes");
00137 alarm.SoundName() = KAlarmSound;
00138
00139
00140 alarm.NextDueTime().HomeTime();
00141
00142
00143 alarm.NextDueTime() += TTimeIntervalSeconds(10);
00144 User::LeaveIfError(iAlarmServerSession.AlarmAdd(alarm));
00145
00146
00147 QString alarmId;
00148 alarmId.setNum(int(alarm.Id()));
00149 emit iPublic->alarmAdded(alarmId);
00150 }
00151
00155 QString AlarmServerExPrivate::ConvertToString(TDateTime time)
00156 {
00157 QString displayText;
00158 displayText.append("Date: ");
00159 QString day;
00160 day.setNum((int)time.Day());
00161 displayText.append(day);
00162 displayText.append("-");
00163 QString month;
00164 month.setNum((int)time.Month());
00165 displayText.append(month);
00166 displayText.append("-");
00167 QString year;
00168 year.setNum((int)time.Year());
00169 displayText.append(year);
00170 displayText.append("\n");
00171 displayText.append("Time: ");
00172 QString hour;
00173 hour.setNum((int)time.Hour());
00174 displayText.append(hour);
00175 displayText.append(":");
00176 QString minute;
00177 minute.setNum((int)time.Minute());
00178 displayText.append(minute);
00179 displayText.append(":");
00180 QString second;
00181 second.setNum((int)time.Second());
00182 displayText.append(second);
00183
00184 return displayText;
00185 }
00186
00190 QString AlarmServerExPrivate::GetAlarmDetails(QString alarmId)
00191 {
00192 TASShdAlarm alarmInfo;
00193
00194
00195 TInt alarm = alarmId.toInt();
00196
00197
00198 iAlarmServerSession.GetAlarmDetails(alarm,alarmInfo);
00199 QString alarmDetails;
00200 alarmDetails.append("\nAlarm ID:\n");
00201 alarmDetails.append(alarmId);
00202
00203
00204 alarmDetails.append("\n\nAlarm State:\n");
00205 TInt state = alarmInfo.State();
00206 if(state == EAlarmStateInPreparation)
00207 alarmDetails.append("Alarm State in preparation.\n");
00208 else if(state == EAlarmStateQueued)
00209 alarmDetails.append("Alarm State Queued.\n");
00210 else if(state == EAlarmStateSnoozed)
00211 alarmDetails.append("Alarm State Snoozed.\n");
00212 else if(state == EAlarmStateWaitingToNotify)
00213 alarmDetails.append("Alarm State waiting to notify.\n");
00214 else if(state == EAlarmStateNotifying)
00215 alarmDetails.append("Alarm State notifying.\n");
00216 else if(state == EAlarmStateNotified)
00217 alarmDetails.append("Alarm State notified.\n");
00218
00219
00220 alarmDetails.append("\nAlarm Due time:\n");
00221 TDateTime dueTime = alarmInfo.NextDueTime().DateTime();
00222 QString displayText = ConvertToString(dueTime);
00223 alarmDetails.append(displayText);
00224
00225
00226 alarmDetails.append("\n\nOriginal time:\n");
00227 TDateTime originalTime = alarmInfo.OriginalExpiryTime().DateTime();
00228 displayText = ConvertToString(originalTime);
00229 alarmDetails.append(displayText);
00230
00231 alarmDetails.append("\n\nAlarm Message :\n");
00232 alarmDetails.append(QString::fromUtf16(alarmInfo.Message().Ptr(),
00233 alarmInfo.Message().Length()));
00234 alarmDetails.append("\n\nSound Name :\n");
00235 alarmDetails.append(QString::fromUtf16(alarmInfo.SoundName().Ptr(),
00236 alarmInfo.SoundName().Length()));
00237
00238 return alarmDetails;
00239 }
00240