crecentcalls.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #include "crecentcalls.h"
  2. //#include <aknnotewrappers.h>
  3. #include <e32base.h>
  4. #include <logcli.h> // CLogClient
  5. #include <logview.h> // CLogViewRecent
  6. #include <logwrap.h> // CLogEvent
  7. #include <logwraplimits.h>
  8. #include <QDebug>
  9. /**
  10. * Constructor. Defines the priority for this active object.
  11. */
  12. CRecentCalls::CRecentCalls() : CActive(EPriorityStandard)
  13. {
  14. }
  15. /**
  16. * 2nd phase constructor.
  17. */
  18. CRecentCalls* CRecentCalls::NewL()
  19. {
  20. CRecentCalls* self = new (ELeave) CRecentCalls();
  21. CleanupStack::PushL(self);
  22. self->ConstructL();
  23. CleanupStack::Pop(self);
  24. return self;
  25. }
  26. /**
  27. * 2nd phase constructor.
  28. */
  29. void CRecentCalls::ConstructL()
  30. {
  31. CActiveScheduler::Add(this);
  32. User::LeaveIfError(iFs.Connect());
  33. // Establish connection to log engine
  34. iLogClient = CLogClient::NewL(iFs);
  35. iLogViewRecent = CLogViewRecent::NewL(*iLogClient);
  36. iTask = ESleep; // Default task for RunL
  37. }
  38. /**
  39. * Destructor.
  40. */
  41. CRecentCalls::~CRecentCalls()
  42. {
  43. Cancel();
  44. delete iLogViewRecent;
  45. delete iLogClient;
  46. iFs.Close();
  47. }
  48. /**
  49. * From CActive.
  50. */
  51. void CRecentCalls::RunL() {
  52. /*switch (iTask) {
  53. case EGetRecent:
  54. {
  55. // Retrieve the event and handle it
  56. HandleRecentEventL(iLogViewRecent->Event());
  57. // If there are more events in the log engine database...
  58. if (iLogViewRecent->NextL(iStatus))
  59. {
  60. if (iStatus == KErrNone)
  61. {
  62. // ... set active to get the next one
  63. SetActive();
  64. }
  65. }
  66. else
  67. {
  68. // No more events. Go to sleep.
  69. iTask = ESleep;
  70. }
  71. break;
  72. }
  73. case ESleep:
  74. default:
  75. {
  76. break;
  77. }
  78. }*/
  79. }
  80. /**
  81. * From CActive.
  82. */
  83. TInt CRecentCalls::RunError(TInt anError)
  84. {
  85. return anError;
  86. }
  87. /**
  88. * From CActive.
  89. */
  90. void CRecentCalls::DoCancel() {
  91. // Cancel the appropriate task
  92. switch (iTask) {
  93. case EGetRecent: {
  94. iLogViewRecent->Cancel();
  95. }
  96. case ESleep:
  97. default:
  98. {
  99. break;
  100. }
  101. }
  102. }
  103. /**
  104. * Reads recent events from the main event database
  105. */
  106. void CRecentCalls::ReadRecentEventsL()
  107. {
  108. iStatus = EReadingLog;
  109. iLogViewRecent->Cancel();
  110. qDebug() << (( iLogViewRecent != NULL ) ? "No null" : "IS NULL");
  111. if(iLogViewRecent->SetRecentListL(KLogNullRecentList, iStatus)) {
  112. if (iStatus == KErrNone) {
  113. // If there are events in the log view, set this active object active
  114. // to get the events from the main event database. See RunL().
  115. iTask = EGetRecent;
  116. SetActive();
  117. }
  118. } else {
  119. // StartL();
  120. /* _LIT(KTxt, "No recent calls.");
  121. CAknInformationNote* note = new (ELeave)CAknInformationNote(ETrue);
  122. note->ExecuteLD(KTxt);*/
  123. qDebug() << "No recent calls";
  124. }
  125. }
  126. /**
  127. * Displays a recent event in an information note.
  128. */
  129. void CRecentCalls::HandleRecentEventL(const CLogEvent& anEvent) {
  130. /*TBuf<255> buffer;
  131. _LIT(KTxt, "Description: %S\nNumber: %S");
  132. buffer.Format(KTxt, &(anEvent.Description()), &(anEvent.Number()));
  133. CAknInformationNote* note = new (ELeave)CAknInformationNote(ETrue);
  134. note->ExecuteLD(buffer);*/
  135. qDebug() << "Number:";
  136. }