// ----------------------------------------------------------------------------- // CPIMAgnToDoAdapter::AlarmOffsetL // Calculates PIM alarm offset for native Calendar entry // The offset calculation is done by calculating the difference between the // due date and the alarm offset. After we know the alarm date and time we // calculate difference between calender specific todo due date (which now is // 00:00) // // For example: // // If our due time is 23:00 and the alarm offset is 900 seconds before it. // Then the alarm should launch at 22:45 at the same day. So, the offset which // we have to write to the native alarm is the difference between 00:00 and 22:45 // which is a negative value because the alarm rises in the future. This all is // done because the calendar understands only the date of the due date and not the // exact time of it. The time is ignored and set to 00:00 by default. // ----------------------------------------------------------------------------- // TTimeIntervalMinutes CPIMAgnToDoAdapter::AlarmOffsetL( const MPIMItemData& aItemData, CCalEntry& aEntry) { JELOG2(EPim); // Note that start time must be set before alarm can be calculated // Add start to the item so alarm can be properly converted. The // native entry does not accept alarm value if start is not present // Due has been already set to default time (current home time) if // ToDo due field is not present in the field so start should be present if (!aItemData.CountValues(EPIMToDoDue)) { User::Leave(KErrArgument); } else { ConvertDateToAgnL(EPIMToDoDue, 0, aEntry, aItemData); } __ASSERT_DEBUG(aEntry.StartTimeL().TimeUtcL() != Time::NullTTime(), User::Panic(KPIMPanicCategory, EPIMPanicInvalidState)); // Get alarm value from the Java item. There should be only one alarm // value supported by the PIM API because native entries do not support // multiple alarm values. const TPIMFieldData alarmData = aItemData.ValueL(EPIMToDoExtAlarm, 0); TInt value = alarmData.IntegerValue(); // Count the alarm value from the start date of the event TTime entryStart = aEntry.StartTimeL().TimeLocalL(); const TPIMFieldData dateData = aItemData.ValueL(EPIMToDoDue, 0); TPIMDate dueDate(dateData.DateValue()); ConvertTimeL(dueDate, EPIMDateLocal); TTimeIntervalSeconds temp(0); User::LeaveIfError(entryStart.SecondsFrom(dueDate, temp)); // Add difference between PIM API start and start which has been // converted to the item (in case if the date has been changed, it is // reflected here) value += temp.Int(); // Check that if the alarm has passed to the following day. In this case, // the alarm is transferred back to 12 o'clock of the current start date TTime alarmTime(entryStart - TTimeIntervalSeconds(value)); // Temporary date. This date is used when calculating if the alarm // value has passed to the following date. TTime startOfNextDay(StartOfDay(dueDate + TTimeIntervalDays(1))); if (alarmTime >= startOfNextDay) { alarmTime = StartOfDay(entryStart); alarmTime += TTimeIntervalSeconds(KPIMDefaultAlarmInterval); User::LeaveIfError(entryStart.SecondsFrom(alarmTime, temp)); value = temp.Int(); } // Convert seconds to minutes return TTimeIntervalMinutes(value / KPIMSecondsInMinute); }
// ----------------------------------------------------------------------------- // CPIMAgnToDoAdapter::ConvertDateToAgnL // Makes date conversion from framework PIM item data field to To-do item field. // ----------------------------------------------------------------------------- // void CPIMAgnToDoAdapter::ConvertDateToAgnL(TPIMToDoField aField, // Date field to be converted TInt aIndex, // Index of the date field CCalEntry& aEntry, const MPIMItemData& aItem) // The PIM item to read the field from { JELOG2(EPim); const TPIMFieldData fieldData = aItem.ValueL(aField, aIndex); const TPIMDate& date = fieldData.DateValue(); switch (aField) { case EPIMToDoDue: { // Because undated to-dos are possible, the due date can be set // to a null value. if (date != Time::NullTTime() && !IsDateInValidAgendaRange(date)) { User::Leave(KErrAbort); } // Java dates cannot be set to native null TTime else { // Convert due date and time to calendar specific due time // Note that PIM API dates are in UTC time format -> convert TTime dueDate(date); ConvertTimeL(dueDate, EPIMDateLocal); // Set time to native entry. Note that the time is local TCalTime calDate; calDate.SetTimeLocalL(StartOfDay(dueDate)); aEntry.SetStartAndEndTimeL(calDate, calDate); } break; } case EPIMToDoCompletionDate: { if (date != Time::NullTTime()) { __ASSERT_ALWAYS(IsDateInValidAgendaRange(date), User::Leave( KErrAbort)); TCalTime calDate; calDate.SetTimeUtcL(date); aEntry.SetCompletedL(ETrue, calDate); } else { aEntry.SetCompletedL(EFalse, aEntry.CompletedTimeL()); } break; } default: { __ASSERT_DEBUG(EFalse, User::Panic(KPIMPanicCategory, EPIMPanicUnsupportedField)); } } }
QString TAEval::serveRequest(QString request, QString data) { //Then find the request here and delegate the data to the SQL to query the required info. if(request.compare("loginRequest") == 0){ qDebug() << "Login Request being processed" << endl; QString l = accessControl.logIn(data); if(l.contains("Instructor")) { return QString("Instructor"); } if(l.contains("TA")) { return QString("TA"); } if(l.contains("loggedin")) { return QString("loggedin"); } else return QString("false"); } else if (request.compare("semesterRequest") == 0) { qDebug() << "Semester Request being processed" << endl; StringList *semesters; if(getSemesters(data, semesters)) { QString result = listToString(*semesters); delete semesters; return result.isEmpty() ? "false" : result; } } else if (request.compare("coursesRequest") == 0) { qDebug() << "Courses Request being processed" << endl; QStringList info = data.split("|"); qDebug() << info.at(0) + " " + info.at(1) << endl; CourseList* c; if(getCourses(info.at(0), c, info.at(0), info.at(1))) { QString stringOfCourses = Course::listToString(*c); qDebug() << stringOfCourses << endl; delete c; return (stringOfCourses.isEmpty()) ? "false" : stringOfCourses; } } else if (request.compare("tasRequest") == 0) { qDebug() << "TAs Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) + " and " + info.at(1) << endl; TAList* t; if(getTAs(info.at(0), info.at(1), t)) { QString stringOfTAs = TA::listToString(*t);delete t; qDebug() << stringOfTAs << endl; return (stringOfTAs.isEmpty()) ? "false" : stringOfTAs; } } else if (request.compare("taskRequest") == 0) { qDebug() << "Task Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) + " and " + info.at(1) << " and " << info.at(2) << endl; TaskList* taskList; if(getTasks(info.at(0), info.at(1), info.at(2), taskList)) { QString stringOfTask = Task::listToString(*taskList); delete taskList; qDebug() << stringOfTask << endl; return (stringOfTask.isEmpty()) ? "false" : stringOfTask; } else return "false"; } else if (request.compare("taskCreateRequest") == 0) { qDebug() << "Create Task Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) + " and " + info.at(1) << " and " << info.at(2) + " and " + info.at(3) << " and " << info.at(4) << + " and " + info.at(5) << endl; QStringList begDateList = info.at(4).split("-"); QStringList dueDateList = info.at(5).split("-"); QDate begDate(begDateList.at(0).toInt(), begDateList.at(1).toInt(), begDateList.at(2).toInt()); QDate dueDate(dueDateList.at(0).toInt(), dueDateList.at(1).toInt(), dueDateList.at(2).toInt()); return createTask(info.at(0), info.at(1), info.at(2), info.at(3), begDate, dueDate) ? "true" : "false"; } else if (request.compare("taskEditRequest") == 0) { qDebug() << "Edit Task Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) + " and " + info.at(1) + " and " + info.at(2) + " and " + info.at(3) + "and " + info.at(4) << endl; QStringList begDateList = info.at(2).split("-"); QStringList dueDateList = info.at(3).split("-"); QDate begDate(begDateList.at(0).toInt(), begDateList.at(1).toInt(), begDateList.at(2).toInt()); QDate dueDate(dueDateList.at(0).toInt(), dueDateList.at(1).toInt(), dueDateList.at(2).toInt()); return editTask(info.at(0), info.at(1), begDate, dueDate, QString(info.at(4))) ? "true" : "false"; } else if (request.compare("taskDeleteRequest") == 0){ qDebug() << "DELETE Task Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) + " and " + info.at(1) << endl; return deleteTask(info.at(0), QString(info.at(1))) ? "true" : "false"; } else if (request.compare("editEvalRequest") == 0){ qDebug() << "Edit Evail Request being processed" << endl; QStringList info = data.split("|"); return enterEvaluation(info.at(0), info.at(1).toInt(), info.at(2), info.at(3).toInt()) ? "true" : "false"; } else if (request.compare("logOutRequest") == 0){ qDebug() << "LogOut Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) << endl; return accessControl.logOut(info.at(0)) ? "true" : "false"; } qDebug() << "Request Failed" << endl; return "false"; }