Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1159 lines
34 KiB

  1. // ViewRow.cpp: implementation of the CViewRow class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #define __FILE_ID__ 31
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char THIS_FILE[]=__FILE__;
  9. #define new DEBUG_NEW
  10. #endif
  11. //
  12. // The following four arrays of strings are filled during app. startup from
  13. // the string table resource by calling InitStrings
  14. //
  15. CString CViewRow::m_cstrPriorities[FAX_PRIORITY_TYPE_HIGH+1];
  16. CString CViewRow::m_cstrQueueStatus[NUM_JOB_STATUS];
  17. CString CViewRow::m_cstrQueueExtendedStatus[JS_EX_CALL_ABORTED - JS_EX_DISCONNECTED + 1];
  18. CString CViewRow::m_cstrMessageStatus[2];
  19. int CViewRow::m_Alignments[MSG_VIEW_ITEM_END] =
  20. {
  21. LVCFMT_LEFT, // MSG_VIEW_ITEM_ICON
  22. LVCFMT_LEFT, // MSG_VIEW_ITEM_STATUS
  23. LVCFMT_LEFT, // MSG_VIEW_ITEM_SERVER
  24. LVCFMT_RIGHT, // MSG_VIEW_ITEM_NUM_PAGES
  25. LVCFMT_LEFT, // MSG_VIEW_ITEM_CSID
  26. LVCFMT_LEFT, // MSG_VIEW_ITEM_TSID
  27. LVCFMT_RIGHT, // MSG_VIEW_ITEM_SIZE
  28. LVCFMT_LEFT, // MSG_VIEW_ITEM_DEVICE
  29. LVCFMT_RIGHT, // MSG_VIEW_ITEM_RETRIES
  30. LVCFMT_RIGHT, // MSG_VIEW_ITEM_ID
  31. LVCFMT_RIGHT, // MSG_VIEW_ITEM_BROADCAST_ID
  32. LVCFMT_LEFT, // MSG_VIEW_ITEM_CALLER_ID
  33. LVCFMT_LEFT, // MSG_VIEW_ITEM_ROUTING_INFO
  34. LVCFMT_LEFT, // MSG_VIEW_ITEM_DOC_NAME
  35. LVCFMT_LEFT, // MSG_VIEW_ITEM_SUBJECT
  36. LVCFMT_LEFT, // MSG_VIEW_ITEM_RECIPIENT_NAME
  37. LVCFMT_LEFT, // MSG_VIEW_ITEM_RECIPIENT_NUMBER
  38. LVCFMT_LEFT, // MSG_VIEW_ITEM_USER
  39. LVCFMT_LEFT, // MSG_VIEW_ITEM_PRIORITY
  40. LVCFMT_LEFT, // MSG_VIEW_ITEM_ORIG_TIME
  41. LVCFMT_LEFT, // MSG_VIEW_ITEM_SUBMIT_TIME
  42. LVCFMT_LEFT, // MSG_VIEW_ITEM_BILLING
  43. LVCFMT_LEFT, // MSG_VIEW_ITEM_TRANSMISSION_START_TIME
  44. LVCFMT_LEFT, // MSG_VIEW_ITEM_SEND_TIME
  45. LVCFMT_LEFT, // MSG_VIEW_ITEM_EXTENDED_STATUS
  46. LVCFMT_RIGHT, // MSG_VIEW_ITEM_CURRENT_PAGE
  47. LVCFMT_LEFT, // MSG_VIEW_ITEM_SENDER_NAME
  48. LVCFMT_LEFT, // MSG_VIEW_ITEM_SENDER_NUMBER
  49. LVCFMT_LEFT, // MSG_VIEW_ITEM_TRANSMISSION_END_TIME
  50. LVCFMT_RIGHT // MSG_VIEW_ITEM_TRANSMISSION_DURATION
  51. };
  52. int CViewRow::m_TitleResources[MSG_VIEW_ITEM_END] =
  53. {
  54. IDS_COLUMN_ICON, // MSG_VIEW_ITEM_ICON,
  55. IDS_MSG_COLUMN_STATUS, // MSG_VIEW_ITEM_STATUS,
  56. IDS_MSG_COLUMN_SERVER, // MSG_VIEW_ITEM_SERVER,
  57. IDS_MSG_COLUMN_NUM_PAGES, // MSG_VIEW_ITEM_NUM_PAGES,
  58. IDS_MSG_COLUMN_CSID, // MSG_VIEW_ITEM_CSID,
  59. IDS_MSG_COLUMN_TSID, // MSG_VIEW_ITEM_TSID,
  60. IDS_MSG_COLUMN_SIZE, // MSG_VIEW_ITEM_SIZE,
  61. IDS_MSG_COLUMN_DEVICE, // MSG_VIEW_ITEM_DEVICE,
  62. IDS_MSG_COLUMN_RETRIES, // MSG_VIEW_ITEM_RETRIES,
  63. IDS_MSG_COLUMN_JOB_ID, // MSG_VIEW_ITEM_ID,
  64. IDS_MSG_COLUMN_BROADCAST_ID,// MSG_VIEW_ITEM_BROADCAST_ID
  65. IDS_MSG_COLUMN_CALLER_ID, // MSG_VIEW_ITEM_CALLER_ID,
  66. IDS_MSG_COLUMN_ROUTING_INFO,// MSG_VIEW_ITEM_ROUTING_INFO,
  67. IDS_MSG_COLUMN_DOC_NAME, // MSG_VIEW_ITEM_DOC_NAME,
  68. IDS_MSG_COLUMN_SUBJECT, // MSG_VIEW_ITEM_SUBJECT,
  69. IDS_MSG_COLUMN_RECP_NAME, // MSG_VIEW_ITEM_RECIPIENT_NAME,
  70. IDS_MSG_COLUMN_RECP_NUM, // MSG_VIEW_ITEM_RECIPIENT_NUMBER,
  71. IDS_MSG_COLUMN_USER, // MSG_VIEW_ITEM_USER,
  72. IDS_MSG_COLUMN_PRIORITY, // MSG_VIEW_ITEM_PRIORITY,
  73. IDS_MSG_COLUMN_ORIG_TIME, // MSG_VIEW_ITEM_ORIG_TIME,
  74. IDS_MSG_COLUMN_SUBMIT_TIME, // MSG_VIEW_ITEM_SUBMIT_TIME,
  75. IDS_MSG_COLUMN_BILLING, // MSG_VIEW_ITEM_BILLING,
  76. IDS_MSG_COLUMN_TRANSMISSION_START_TIME, // MSG_VIEW_ITEM_TRANSMISSION_START_TIME,
  77. IDS_MSG_COLUMN_SEND_TIME, // MSG_VIEW_ITEM_SEND_TIME,
  78. IDS_MSG_COLUMN_EX_STATUS, // MSG_VIEW_ITEM_EXTENDED_STATUS,
  79. IDS_MSG_COLUMN_CURR_PAGE, // MSG_VIEW_ITEM_CURRENT_PAGE,
  80. IDS_MSG_COLUMN_SENDER_NAME, // MSG_VIEW_ITEM_SENDER_NAME,
  81. IDS_MSG_COLUMN_SENDER_NUM, // MSG_VIEW_ITEM_SENDER_NUMBER,
  82. IDS_MSG_COLUMN_TRANSMISSION_END_TIME, // MSG_VIEW_ITEM_TRANSMISSION_END_TIME,
  83. IDS_MSG_COLUMN_TRANSMISSION_DURATION // MSG_VIEW_ITEM_TRANSMISSION_DURATION,
  84. };
  85. //////////////////////////////////////////////////////////////////////
  86. // Construction/Destruction
  87. //////////////////////////////////////////////////////////////////////
  88. DWORD
  89. CViewRow::InitStrings ()
  90. /*++
  91. Routine name : CViewRow::InitStrings
  92. Routine description:
  93. Loads the static strings used to display status etc.
  94. Static.
  95. Author:
  96. Eran Yariv (EranY), Jan, 2000
  97. Arguments:
  98. Return Value:
  99. Standard Win32 error code
  100. --*/
  101. {
  102. DWORD dwRes = ERROR_SUCCESS;
  103. DBG_ENTER(TEXT("CViewRow::InitStrings"), dwRes);
  104. //
  105. // Load strings used for diaply throughout the application - job status
  106. //
  107. int iStatusIds[] =
  108. {
  109. IDS_PENDING,
  110. IDS_INPROGRESS,
  111. IDS_DELETING,
  112. IDS_PAUSED,
  113. IDS_RETRYING,
  114. IDS_RETRIES_EXCEEDED,
  115. IDS_COMPLETED,
  116. IDS_CANCELED,
  117. IDS_CANCELING,
  118. IDS_ROUTING,
  119. IDS_ROUTING_RETRY,
  120. IDS_ROUTING_INPROGRESS,
  121. IDS_ROUTING_FAILED
  122. };
  123. for (int i = JOB_STAT_PENDING; i < NUM_JOB_STATUS; i++)
  124. {
  125. dwRes = LoadResourceString (m_cstrQueueStatus[i], iStatusIds[i]);
  126. if (ERROR_SUCCESS != dwRes)
  127. {
  128. CALL_FAIL (RESOURCE_ERR, TEXT("LoadResourceString"), dwRes);
  129. return dwRes;
  130. }
  131. }
  132. //
  133. // Load strings used for diaply throughout the application - job extended status
  134. //
  135. int iExtStatusIds[] =
  136. {
  137. IDS_DISCONNECTED,
  138. IDS_INITIALIZING,
  139. IDS_DIALING,
  140. IDS_TRANSMITTING,
  141. IDS_ANSWERED,
  142. IDS_RECEIVING,
  143. IDS_LINE_UNAVAILABLE,
  144. IDS_BUSY,
  145. IDS_NO_ANSWER,
  146. IDS_BAD_ADDRESS,
  147. IDS_NO_DIAL_TONE,
  148. IDS_FATAL_ERROR,
  149. IDS_CALL_DELAYED,
  150. IDS_CALL_BLACKLISTED,
  151. IDS_NOT_FAX_CALL,
  152. IDS_STATUS_PARTIALLY_RECEIVED,
  153. IDS_HANDLED,
  154. IDS_CALL_COMPLETED,
  155. IDS_CALL_ABORTED
  156. };
  157. for (i = 0; i < sizeof(iExtStatusIds) / sizeof (iExtStatusIds[0]); i++)
  158. {
  159. dwRes = LoadResourceString (m_cstrQueueExtendedStatus[i], iExtStatusIds[i]);
  160. if (ERROR_SUCCESS != dwRes)
  161. {
  162. CALL_FAIL (RESOURCE_ERR, TEXT("LoadResourceString"), dwRes);
  163. return dwRes;
  164. }
  165. }
  166. int iPrioritiyIds[] =
  167. {
  168. IDS_LOW_PRIORITY,
  169. IDS_NORMAL_PRIORITY,
  170. IDS_HIGH_PRIORITY
  171. };
  172. for (i = FAX_PRIORITY_TYPE_LOW; i <= FAX_PRIORITY_TYPE_HIGH; i++)
  173. {
  174. dwRes = LoadResourceString (m_cstrPriorities[i], iPrioritiyIds[i]);
  175. if (ERROR_SUCCESS != dwRes)
  176. {
  177. CALL_FAIL (RESOURCE_ERR, TEXT("LoadResourceString"), dwRes);
  178. return dwRes;
  179. }
  180. }
  181. dwRes = LoadResourceString (m_cstrMessageStatus[0], IDS_STATUS_SUCCESS);
  182. if (ERROR_SUCCESS != dwRes)
  183. {
  184. CALL_FAIL (RESOURCE_ERR, TEXT("LoadResourceString"), dwRes);
  185. return dwRes;
  186. }
  187. dwRes = LoadResourceString (m_cstrMessageStatus[1], IDS_STATUS_PARTIALLY_RECEIVED);
  188. if (ERROR_SUCCESS != dwRes)
  189. {
  190. CALL_FAIL (RESOURCE_ERR, TEXT("LoadResourceString"), dwRes);
  191. return dwRes;
  192. }
  193. return dwRes;
  194. } // CViewRow::InitStrings
  195. DWORD
  196. CViewRow::GetItemTitle (
  197. DWORD item,
  198. CString &cstrRes
  199. )
  200. /*++
  201. Routine name : CViewRow::GetItemTitle
  202. Routine description:
  203. Retrieves the title string of an item in the view
  204. Author:
  205. Eran Yariv (EranY), Jan, 2000
  206. Arguments:
  207. item [in ] - Item
  208. cstrRes [out] - String buffer
  209. Return Value:
  210. Standard Win32 error code
  211. --*/
  212. {
  213. DWORD dwRes = ERROR_SUCCESS;
  214. DBG_ENTER(TEXT("CViewRow::GetItemTitle"), dwRes);
  215. ASSERTION (item < MSG_VIEW_ITEM_END);
  216. dwRes = LoadResourceString (cstrRes, m_TitleResources[item]);
  217. if (ERROR_SUCCESS != dwRes)
  218. {
  219. CALL_FAIL (GENERAL_ERR, TEXT("LoadResourceString"), dwRes);
  220. }
  221. return dwRes;
  222. } // CViewRow::GetItemTitle
  223. DWORD
  224. CViewRow::DetachFromMsg()
  225. /*++
  226. Routine name : CViewRow::DetachFromMsg
  227. Routine description:
  228. Ivalidate content, empty all strings
  229. Author:
  230. Alexander Malysh (AlexMay), Apr, 2000
  231. Arguments:
  232. Return Value:
  233. Standard Win32 error code
  234. --*/
  235. {
  236. DWORD dwRes = ERROR_SUCCESS;
  237. DBG_ENTER(TEXT("CViewRow::ResetDisplayStrings"), dwRes);
  238. m_bAttached = FALSE;
  239. m_bStringsPreparedForDisplay = FALSE;
  240. for(DWORD dw=0; dw < MSG_VIEW_ITEM_END; ++dw)
  241. {
  242. try
  243. {
  244. m_Strings[dw].Empty();
  245. }
  246. catch(...)
  247. {
  248. dwRes = ERROR_NOT_ENOUGH_MEMORY;
  249. CALL_FAIL (GENERAL_ERR, TEXT("CString::Empty"), dwRes);
  250. return dwRes;
  251. }
  252. }
  253. return dwRes;
  254. }
  255. DWORD CViewRow::AttachToMsg(
  256. CFaxMsg *pMsg,
  257. BOOL PrepareStrings
  258. )
  259. /*++
  260. Routine name : CViewRow::AttachToMsg
  261. Routine description:
  262. Attach the view row to an existing message.
  263. Author:
  264. Eran Yariv (EranY), Jan, 2000
  265. Arguments:
  266. pMsg [in] - Message to attach to
  267. PrepareStrings [in] - If TRUE, also create internal strings
  268. representation for list display.
  269. Return Value:
  270. Standard Win32 error code
  271. --*/
  272. {
  273. DWORD dwRes = ERROR_SUCCESS;
  274. DBG_ENTER(TEXT("CViewRow::AttachToMsg"), dwRes);
  275. ASSERTION (pMsg);
  276. dwRes = DetachFromMsg();
  277. if(ERROR_SUCCESS != dwRes)
  278. {
  279. CALL_FAIL (GENERAL_ERR, TEXT("DetachFromMsg"), dwRes);
  280. return dwRes;
  281. }
  282. if (PrepareStrings)
  283. {
  284. DWORD dwValidityMask = pMsg->GetValidityMask ();
  285. try
  286. {
  287. //
  288. // Msg id
  289. //
  290. m_Strings[MSG_VIEW_ITEM_ID] = DWORDLONG2String (pMsg->GetId());
  291. //
  292. // Msg broadcast id
  293. //
  294. m_Strings[MSG_VIEW_ITEM_BROADCAST_ID] = (pMsg->GetBroadcastId() != 0) ?
  295. DWORDLONG2String (pMsg->GetBroadcastId()) : TEXT("");
  296. //
  297. // Msg size
  298. //
  299. if (dwValidityMask & FAX_JOB_FIELD_SIZE)
  300. {
  301. dwRes = FaxSizeFormat(pMsg->GetSize(), m_Strings[MSG_VIEW_ITEM_SIZE]);
  302. if(ERROR_SUCCESS != dwRes)
  303. {
  304. CALL_FAIL (GENERAL_ERR, TEXT("FaxSizeFormat"), dwRes);
  305. return dwRes;
  306. }
  307. }
  308. //
  309. // Page count
  310. //
  311. if (dwValidityMask & FAX_JOB_FIELD_PAGE_COUNT)
  312. {
  313. m_Strings[MSG_VIEW_ITEM_NUM_PAGES] = DWORD2String (pMsg->GetNumPages());
  314. }
  315. //
  316. // Original scheduled time
  317. //
  318. if (dwValidityMask & FAX_JOB_FIELD_ORIGINAL_SCHEDULE_TIME)
  319. {
  320. m_Strings[MSG_VIEW_ITEM_ORIG_TIME] =
  321. pMsg->GetOrigTime().FormatByUserLocale ();
  322. }
  323. //
  324. // Submission time
  325. //
  326. if (dwValidityMask & FAX_JOB_FIELD_SUBMISSION_TIME)
  327. {
  328. m_Strings[MSG_VIEW_ITEM_SUBMIT_TIME] =
  329. pMsg->GetSubmissionTime().FormatByUserLocale ();
  330. }
  331. //
  332. // Transmission start time
  333. //
  334. if (dwValidityMask & FAX_JOB_FIELD_TRANSMISSION_START_TIME)
  335. {
  336. m_Strings[MSG_VIEW_ITEM_TRANSMISSION_START_TIME] =
  337. pMsg->GetTransmissionStartTime().FormatByUserLocale ();
  338. }
  339. //
  340. // Transmission end time
  341. //
  342. if (dwValidityMask & FAX_JOB_FIELD_TRANSMISSION_END_TIME)
  343. {
  344. m_Strings[MSG_VIEW_ITEM_TRANSMISSION_END_TIME] =
  345. pMsg->GetTransmissionEndTime().FormatByUserLocale ();
  346. }
  347. //
  348. // Priority
  349. //
  350. if (dwValidityMask & FAX_JOB_FIELD_PRIORITY)
  351. {
  352. m_Strings[MSG_VIEW_ITEM_PRIORITY] = m_cstrPriorities[pMsg->GetPriority()];
  353. }
  354. //
  355. // Retries
  356. //
  357. if (dwValidityMask & FAX_JOB_FIELD_RETRIES)
  358. {
  359. m_Strings[MSG_VIEW_ITEM_RETRIES] = DWORD2String (pMsg->GetRetries());
  360. }
  361. //
  362. // Recipient info
  363. //
  364. m_Strings[MSG_VIEW_ITEM_RECIPIENT_NUMBER] = pMsg->GetRecipientNumber();
  365. #ifdef UNICODE
  366. if(theApp.IsRTLUI())
  367. {
  368. //
  369. // Phone number always should be LTR
  370. // Add LEFT-TO-RIGHT OVERRIDE (LRO)
  371. //
  372. m_Strings[MSG_VIEW_ITEM_RECIPIENT_NUMBER].Insert(0, UNICODE_LRO);
  373. }
  374. #endif
  375. m_Strings[MSG_VIEW_ITEM_RECIPIENT_NAME] = pMsg->GetRecipientName();
  376. //
  377. // TSID / CSID
  378. //
  379. m_Strings[MSG_VIEW_ITEM_TSID] = pMsg->GetTSID();
  380. m_Strings[MSG_VIEW_ITEM_CSID] = pMsg->GetCSID();
  381. //
  382. // User
  383. //
  384. m_Strings[MSG_VIEW_ITEM_USER] = pMsg->GetUser();
  385. //
  386. // Billing
  387. //
  388. m_Strings[MSG_VIEW_ITEM_BILLING] = pMsg->GetBilling();
  389. //
  390. // Device
  391. //
  392. m_Strings[MSG_VIEW_ITEM_DEVICE] = pMsg->GetDevice();
  393. //
  394. // Document
  395. //
  396. m_Strings[MSG_VIEW_ITEM_DOC_NAME] = pMsg->GetDocName();
  397. //
  398. // Subject
  399. //
  400. m_Strings[MSG_VIEW_ITEM_SUBJECT] = pMsg->GetSubject();
  401. //
  402. // Caller id
  403. //
  404. m_Strings[MSG_VIEW_ITEM_CALLER_ID] = pMsg->GetCallerId();
  405. //
  406. // Routing info
  407. //
  408. m_Strings[MSG_VIEW_ITEM_ROUTING_INFO] = pMsg->GetRoutingInfo();
  409. //
  410. // Server name
  411. //
  412. m_Strings[MSG_VIEW_ITEM_SERVER] = pMsg->GetServerName();
  413. if(m_Strings[MSG_VIEW_ITEM_SERVER].GetLength() == 0)
  414. {
  415. dwRes = LoadResourceString(m_Strings[MSG_VIEW_ITEM_SERVER],
  416. IDS_LOCAL_SERVER);
  417. if(ERROR_SUCCESS != dwRes)
  418. {
  419. CALL_FAIL (GENERAL_ERR, TEXT("LoadResourceString"), dwRes);
  420. return dwRes;
  421. }
  422. }
  423. //
  424. // Icon
  425. //
  426. m_Icon = CalcIcon (pMsg);
  427. dwRes = InitStatusStr(pMsg);
  428. if(ERROR_SUCCESS != dwRes)
  429. {
  430. CALL_FAIL (GENERAL_ERR, TEXT("CViewRow::InitStatusStr"), dwRes);
  431. return dwRes;
  432. }
  433. dwRes = InitExtStatusStr(pMsg);
  434. if(ERROR_SUCCESS != dwRes)
  435. {
  436. CALL_FAIL (GENERAL_ERR, TEXT("CViewRow::InitExtStatusStr"), dwRes);
  437. return dwRes;
  438. }
  439. if(pMsg->IsKindOf(RUNTIME_CLASS(CArchiveMsg)))
  440. {
  441. //
  442. // Sender info
  443. //
  444. m_Strings[MSG_VIEW_ITEM_SENDER_NUMBER] = pMsg->GetSenderNumber();
  445. #ifdef UNICODE
  446. if(theApp.IsRTLUI())
  447. {
  448. //
  449. // Phone number always should be LTR
  450. // Add LEFT-TO-RIGHT OVERRIDE (LRO)
  451. //
  452. m_Strings[MSG_VIEW_ITEM_SENDER_NUMBER].Insert(0, UNICODE_LRO);
  453. }
  454. #endif
  455. m_Strings[MSG_VIEW_ITEM_SENDER_NAME] = pMsg->GetSenderName();
  456. //
  457. // Transmission duration
  458. //
  459. if ((dwValidityMask & FAX_JOB_FIELD_TRANSMISSION_END_TIME) &&
  460. (dwValidityMask & FAX_JOB_FIELD_TRANSMISSION_START_TIME))
  461. {
  462. m_Strings[MSG_VIEW_ITEM_TRANSMISSION_DURATION] =
  463. pMsg->GetTransmissionDuration().FormatByUserLocale ();
  464. }
  465. }
  466. else if(pMsg->IsKindOf(RUNTIME_CLASS(CJob)))
  467. {
  468. //
  469. // Current page
  470. //
  471. if (dwValidityMask & FAX_JOB_FIELD_CURRENT_PAGE)
  472. {
  473. m_Strings[MSG_VIEW_ITEM_CURRENT_PAGE] =
  474. DWORD2String (pMsg->GetCurrentPage());
  475. }
  476. //
  477. // Send time
  478. //
  479. if (dwValidityMask & FAX_JOB_FIELD_SCHEDULE_TIME)
  480. {
  481. m_Strings[MSG_VIEW_ITEM_SEND_TIME] =
  482. pMsg->GetScheduleTime().FormatByUserLocale ();
  483. }
  484. }
  485. else
  486. {
  487. ASSERTION_FAILURE
  488. }
  489. }
  490. catch (CException *pException)
  491. {
  492. TCHAR wszCause[1024];
  493. pException->GetErrorMessage (wszCause, 1024);
  494. pException->Delete ();
  495. VERBOSE (EXCEPTION_ERR,
  496. TEXT("CJob::Init caused exception : %s"),
  497. wszCause);
  498. dwRes = ERROR_NOT_ENOUGH_MEMORY;
  499. return dwRes;
  500. }
  501. m_bStringsPreparedForDisplay = TRUE;
  502. }
  503. ASSERTION (ERROR_SUCCESS == dwRes);
  504. m_bAttached = TRUE;
  505. m_pMsg = pMsg;
  506. return dwRes;
  507. } // CViewRow::AttachToMessage
  508. DWORD
  509. CViewRow::InitStatusStr(
  510. CFaxMsg *pMsg
  511. )
  512. /*++
  513. Routine name : CViewRow::InitStatusStr
  514. Routine description:
  515. Init m_Strings[MSG_VIEW_ITEM_STATUS] string with status
  516. Arguments:
  517. pMsg [in] - CFaxMsg
  518. Return Value:
  519. error code
  520. --*/
  521. {
  522. DWORD dwRes = ERROR_SUCCESS;
  523. DBG_ENTER(TEXT("CViewRow::InitStatusStr"));
  524. ASSERTION(pMsg);
  525. try
  526. {
  527. DWORD dwValidityMask = pMsg->GetValidityMask ();
  528. if(pMsg->IsKindOf(RUNTIME_CLASS(CArchiveMsg)))
  529. {
  530. //
  531. // Status
  532. //
  533. switch (pMsg->GetType())
  534. {
  535. case JT_RECEIVE:
  536. //
  537. // Received message
  538. //
  539. if ((pMsg->GetExtendedStatus ()) == JS_EX_PARTIALLY_RECEIVED)
  540. {
  541. //
  542. // Partially received fax
  543. //
  544. m_Strings[MSG_VIEW_ITEM_STATUS] = m_cstrMessageStatus[1];
  545. }
  546. else
  547. {
  548. //
  549. // Fully received fax
  550. //
  551. m_Strings[MSG_VIEW_ITEM_STATUS] = m_cstrMessageStatus[0];
  552. }
  553. break;
  554. case JT_SEND:
  555. //
  556. // Sent message
  557. //
  558. m_Strings[MSG_VIEW_ITEM_STATUS] = m_cstrMessageStatus[0];
  559. break;
  560. default:
  561. ASSERTION_FAILURE;
  562. m_Strings[MSG_VIEW_ITEM_STATUS].Empty ();
  563. break;
  564. }
  565. }
  566. else if(pMsg->IsKindOf(RUNTIME_CLASS(CJob)))
  567. {
  568. //
  569. // Queue status
  570. //
  571. ASSERTION (dwValidityMask & FAX_JOB_FIELD_QUEUE_STATUS);
  572. JobStatusType stat = pMsg->GetStatus();
  573. BOOL bValidStatus = TRUE;
  574. ASSERTION ((stat >= JOB_STAT_PENDING) && (stat < NUM_JOB_STATUS));
  575. if(pMsg->GetType() == JT_ROUTING)
  576. {
  577. switch(stat)
  578. {
  579. case JOB_STAT_INPROGRESS:
  580. stat = JOB_STAT_ROUTING_INPROGRESS;
  581. break;
  582. case JOB_STAT_RETRYING:
  583. stat = JOB_STAT_ROUTING_RETRY;
  584. break;
  585. case JOB_STAT_RETRIES_EXCEEDED:
  586. stat = JOB_STAT_ROUTING_FAILED;
  587. break;
  588. default:
  589. //
  590. // Future / unknown job status
  591. //
  592. bValidStatus = FALSE;
  593. break;
  594. };
  595. }
  596. if (bValidStatus)
  597. {
  598. m_Strings[MSG_VIEW_ITEM_STATUS] = m_cstrQueueStatus[stat];
  599. }
  600. else
  601. {
  602. //
  603. // Unknown (future) status - use empty etring
  604. //
  605. m_Strings[MSG_VIEW_ITEM_STATUS].Empty();
  606. }
  607. }
  608. else
  609. {
  610. ASSERTION_FAILURE;
  611. }
  612. }
  613. catch(CException *pException)
  614. {
  615. TCHAR szCause[MAX_PATH];
  616. if(pException->GetErrorMessage(szCause, ARR_SIZE(szCause)))
  617. {
  618. VERBOSE (EXCEPTION_ERR, TEXT("%s"), szCause);
  619. }
  620. pException->Delete();
  621. dwRes = ERROR_NOT_ENOUGH_MEMORY;
  622. }
  623. return dwRes;
  624. }
  625. DWORD
  626. CViewRow::InitExtStatusStr(
  627. CFaxMsg *pMsg
  628. )
  629. /*++
  630. Routine name : CViewRow::InitExtStatusStr
  631. Routine description:
  632. Init m_Strings[MSG_VIEW_ITEM_EXTENDED_STATUS] string with extended status
  633. Arguments:
  634. pMsg [in] - CFaxMsg
  635. Return Value:
  636. error code
  637. --*/
  638. {
  639. DWORD dwRes = ERROR_SUCCESS;
  640. DBG_ENTER(TEXT("CViewRow::InitExtStatusStr"));
  641. ASSERTION(pMsg);
  642. try
  643. {
  644. if(pMsg->IsKindOf(RUNTIME_CLASS(CJob)))
  645. {
  646. //
  647. // Extended status
  648. // Check for extended status string first
  649. //
  650. if (pMsg->GetExtendedStatusString().IsEmpty())
  651. {
  652. //
  653. // Empty extended status string, check for well known extended status
  654. //
  655. DWORD dwValidityMask = pMsg->GetValidityMask ();
  656. if ((dwValidityMask & FAX_JOB_FIELD_STATUS_EX))
  657. {
  658. //
  659. // Extended status code is reported
  660. //
  661. DWORD dwExtStatus = pMsg->GetExtendedStatus ();
  662. ASSERTION (dwExtStatus >= JS_EX_DISCONNECTED);
  663. if (dwExtStatus > FAX_API_VER_1_MAX_JS_EX)
  664. {
  665. //
  666. // Unknown (future) extended status - use blank string
  667. //
  668. m_Strings[MSG_VIEW_ITEM_EXTENDED_STATUS].Empty();
  669. }
  670. else
  671. {
  672. //
  673. // Predefined extended status
  674. //
  675. m_Strings[MSG_VIEW_ITEM_EXTENDED_STATUS] =
  676. m_cstrQueueExtendedStatus[dwExtStatus - JS_EX_DISCONNECTED];
  677. }
  678. }
  679. }
  680. else
  681. {
  682. //
  683. // We have an extended status string, display it
  684. //
  685. m_Strings[MSG_VIEW_ITEM_EXTENDED_STATUS] =
  686. pMsg->GetExtendedStatusString();
  687. }
  688. }
  689. }
  690. catch(CException *pException)
  691. {
  692. TCHAR szCause[MAX_PATH];
  693. if(pException->GetErrorMessage(szCause, ARR_SIZE(szCause)))
  694. {
  695. VERBOSE (EXCEPTION_ERR, TEXT("%s"), szCause);
  696. }
  697. pException->Delete();
  698. dwRes = ERROR_NOT_ENOUGH_MEMORY;
  699. }
  700. return dwRes;
  701. }
  702. IconType
  703. CViewRow::CalcIcon(
  704. CFaxMsg *pMsg
  705. )
  706. {
  707. DBG_ENTER(TEXT("CViewRow::CalcIcon"));
  708. ASSERTION(pMsg);
  709. IconType icon = INVALID;
  710. if(pMsg->IsKindOf(RUNTIME_CLASS(CArchiveMsg)))
  711. {
  712. icon = CalcMessageIcon(pMsg);
  713. }
  714. else if(pMsg->IsKindOf(RUNTIME_CLASS(CJob)))
  715. {
  716. icon = CalcJobIcon(pMsg);
  717. }
  718. else
  719. {
  720. ASSERTION_FAILURE
  721. }
  722. return icon;
  723. }
  724. IconType
  725. CViewRow::CalcJobIcon(
  726. CFaxMsg *pJob
  727. )
  728. {
  729. DBG_ENTER(TEXT("CViewRow::CalcJobIcon"));
  730. ASSERTION(pJob);
  731. int iStatus = pJob->GetStatus();
  732. ASSERTION (pJob->GetValidityMask() & FAX_JOB_FIELD_STATUS_SUB_STRUCT);
  733. ASSERTION (pJob->GetValidityMask() && FAX_JOB_FIELD_TYPE);
  734. switch (pJob->GetType())
  735. {
  736. case JT_ROUTING:
  737. //
  738. // Routing job
  739. //
  740. switch (iStatus)
  741. {
  742. case JOB_STAT_PENDING:
  743. case JOB_STAT_DELETING:
  744. case JOB_STAT_RETRYING:
  745. case JOB_STAT_CANCELING:
  746. case JOB_STAT_INPROGRESS:
  747. return LIST_IMAGE_ROUTING;
  748. break;
  749. case JOB_STAT_RETRIES_EXCEEDED:
  750. return LIST_IMAGE_ERROR;
  751. break;
  752. default:
  753. //
  754. // We don't allow MSG_STAT_COMPLETED, MSG_STAT_PAUSED,
  755. // and MSG_STAT_CANCELED.
  756. //
  757. ASSERTION_FAILURE;
  758. return INVALID;
  759. }
  760. break;
  761. case JT_RECEIVE:
  762. //
  763. // Receiving job
  764. //
  765. switch (iStatus)
  766. {
  767. case JOB_STAT_CANCELING:
  768. case JOB_STAT_INPROGRESS:
  769. case JOB_STAT_ROUTING:
  770. return LIST_IMAGE_RECEIVING;
  771. break;
  772. default:
  773. //
  774. // We don't allow MSG_STAT_COMPLETED, MSG_STAT_PAUSED,
  775. // MSG_STAT_PENDING, MSG_STAT_DELETING,
  776. // MSG_STAT_RETRYING
  777. // MSG_STAT_RETRIES_EXCEEDED,
  778. // and MSG_STAT_CANCELED.
  779. //
  780. ASSERTION_FAILURE;
  781. return INVALID;
  782. }
  783. break;
  784. case JT_SEND:
  785. switch (iStatus)
  786. {
  787. case JOB_STAT_PENDING:
  788. case JOB_STAT_DELETING:
  789. case JOB_STAT_RETRYING:
  790. case JOB_STAT_CANCELING:
  791. case JOB_STAT_COMPLETED:
  792. case JOB_STAT_CANCELED:
  793. return LIST_IMAGE_NORMAL_MESSAGE;
  794. break;
  795. case JOB_STAT_RETRIES_EXCEEDED:
  796. return LIST_IMAGE_ERROR;
  797. break;
  798. case JOB_STAT_PAUSED:
  799. return LIST_IMAGE_PAUSED;
  800. break;
  801. case JOB_STAT_INPROGRESS:
  802. return LIST_IMAGE_SENDING;
  803. break;
  804. default:
  805. //
  806. // Unknown job status
  807. //
  808. ASSERTION_FAILURE;
  809. return INVALID;
  810. }
  811. break;
  812. default:
  813. ASSERTION_FAILURE;
  814. return INVALID;
  815. }
  816. }
  817. IconType
  818. CViewRow::CalcMessageIcon(
  819. CFaxMsg *pMsg
  820. )
  821. {
  822. DBG_ENTER(TEXT("CViewRow::CalcMessageIcon"));
  823. ASSERTION(pMsg);
  824. switch (pMsg->GetType())
  825. {
  826. case JT_RECEIVE:
  827. //
  828. // Received message
  829. //
  830. if ((pMsg->GetExtendedStatus ()) == JS_EX_PARTIALLY_RECEIVED)
  831. {
  832. //
  833. // Partially received fax
  834. //
  835. return LIST_IMAGE_PARTIALLY_RECEIVED;
  836. }
  837. else
  838. {
  839. //
  840. // Fully received fax
  841. //
  842. return LIST_IMAGE_SUCCESS;
  843. }
  844. break;
  845. case JT_SEND:
  846. return LIST_IMAGE_SUCCESS;
  847. default:
  848. ASSERTION_FAILURE;
  849. return INVALID;
  850. }
  851. }
  852. int
  853. CViewRow::CompareByItem (
  854. CViewRow &other,
  855. DWORD item
  856. )
  857. /*++
  858. Routine name : CViewRow::CompareByItem
  859. Routine description:
  860. Compares a list item against another one
  861. Author:
  862. Eran Yariv (EranY), Jan, 2000
  863. Arguments:
  864. other [in] - Other list item
  865. item [in] - Item to compare by
  866. Return Value:
  867. -1 if smaler than other, 0 if identical, +1 if bigger than other
  868. --*/
  869. {
  870. DWORD dwRes = ERROR_SUCCESS;
  871. DBG_ENTER(TEXT("CViewRow::CompareByItem"));
  872. ASSERTION (item < MSG_VIEW_ITEM_END);
  873. ASSERTION (m_bAttached && other.m_bAttached);
  874. if(other.m_pMsg->IsKindOf(RUNTIME_CLASS(CJob)) !=
  875. m_pMsg->IsKindOf(RUNTIME_CLASS(CJob)))
  876. {
  877. ASSERTION_FAILURE;
  878. return 1;
  879. }
  880. switch (item)
  881. {
  882. case MSG_VIEW_ITEM_ICON:
  883. case MSG_VIEW_ITEM_STATUS:
  884. dwRes = InitStatusStr(m_pMsg);
  885. if(ERROR_SUCCESS != dwRes)
  886. {
  887. CALL_FAIL (GENERAL_ERR, TEXT("CViewRow::InitStatusStr"), dwRes);
  888. return 0;
  889. }
  890. dwRes = other.InitStatusStr(other.m_pMsg);
  891. if(ERROR_SUCCESS != dwRes)
  892. {
  893. CALL_FAIL (GENERAL_ERR, TEXT("CViewRow::InitStatusStr"), dwRes);
  894. return 0;
  895. }
  896. return m_Strings[MSG_VIEW_ITEM_STATUS].Compare(other.m_Strings[MSG_VIEW_ITEM_STATUS]);
  897. case MSG_VIEW_ITEM_EXTENDED_STATUS:
  898. dwRes = InitExtStatusStr(m_pMsg);
  899. if(ERROR_SUCCESS != dwRes)
  900. {
  901. CALL_FAIL (GENERAL_ERR, TEXT("CViewRow::InitStatusStr"), dwRes);
  902. return 0;
  903. }
  904. dwRes = other.InitExtStatusStr(other.m_pMsg);
  905. if(ERROR_SUCCESS != dwRes)
  906. {
  907. CALL_FAIL (GENERAL_ERR, TEXT("CViewRow::InitStatusStr"), dwRes);
  908. return 0;
  909. }
  910. return m_Strings[item].Compare(other.m_Strings[item]);
  911. case MSG_VIEW_ITEM_SERVER:
  912. return m_pMsg->GetServerName().Compare (other.m_pMsg->GetServerName());
  913. case MSG_VIEW_ITEM_CSID:
  914. return m_pMsg->GetCSID().Compare (other.m_pMsg->GetCSID());
  915. case MSG_VIEW_ITEM_TSID:
  916. return m_pMsg->GetTSID().Compare (other.m_pMsg->GetTSID());
  917. case MSG_VIEW_ITEM_DEVICE:
  918. return m_pMsg->GetDevice().Compare (other.m_pMsg->GetDevice());
  919. case MSG_VIEW_ITEM_CALLER_ID:
  920. return m_pMsg->GetCallerId().Compare (other.m_pMsg->GetCallerId());
  921. case MSG_VIEW_ITEM_ROUTING_INFO:
  922. return m_pMsg->GetRoutingInfo().Compare (other.m_pMsg->GetRoutingInfo());
  923. case MSG_VIEW_ITEM_DOC_NAME:
  924. return m_pMsg->GetDocName().Compare (other.m_pMsg->GetDocName());
  925. case MSG_VIEW_ITEM_SUBJECT:
  926. return m_pMsg->GetSubject().Compare (other.m_pMsg->GetSubject());
  927. case MSG_VIEW_ITEM_RECIPIENT_NAME:
  928. return m_pMsg->GetRecipientName().Compare (other.m_pMsg->GetRecipientName());
  929. case MSG_VIEW_ITEM_RECIPIENT_NUMBER:
  930. return m_pMsg->GetRecipientNumber().Compare (other.m_pMsg->GetRecipientNumber());
  931. case MSG_VIEW_ITEM_USER:
  932. return m_pMsg->GetUser().Compare (other.m_pMsg->GetUser());
  933. case MSG_VIEW_ITEM_PRIORITY:
  934. return NUMERIC_CMP(m_pMsg->GetPriority(), other.m_pMsg->GetPriority());
  935. case MSG_VIEW_ITEM_BILLING:
  936. return m_pMsg->GetBilling().Compare (other.m_pMsg->GetBilling());
  937. case MSG_VIEW_ITEM_NUM_PAGES:
  938. return NUMERIC_CMP(m_pMsg->GetNumPages(), other.m_pMsg->GetNumPages());
  939. case MSG_VIEW_ITEM_CURRENT_PAGE:
  940. return NUMERIC_CMP(m_pMsg->GetCurrentPage(), other.m_pMsg->GetCurrentPage());
  941. case MSG_VIEW_ITEM_TRANSMISSION_START_TIME:
  942. return m_pMsg->GetTransmissionStartTime().Compare (
  943. other.m_pMsg->GetTransmissionStartTime());
  944. case MSG_VIEW_ITEM_SIZE:
  945. return NUMERIC_CMP(m_pMsg->GetSize(), other.m_pMsg->GetSize());
  946. case MSG_VIEW_ITEM_RETRIES:
  947. return NUMERIC_CMP(m_pMsg->GetRetries(), other.m_pMsg->GetRetries());
  948. case MSG_VIEW_ITEM_ID:
  949. return NUMERIC_CMP(m_pMsg->GetId(), other.m_pMsg->GetId());
  950. case MSG_VIEW_ITEM_BROADCAST_ID:
  951. return NUMERIC_CMP(m_pMsg->GetBroadcastId(), other.m_pMsg->GetBroadcastId());
  952. case MSG_VIEW_ITEM_ORIG_TIME:
  953. return m_pMsg->GetOrigTime().Compare (
  954. other.m_pMsg->GetOrigTime());
  955. case MSG_VIEW_ITEM_SUBMIT_TIME:
  956. return m_pMsg->GetSubmissionTime().Compare (
  957. other.m_pMsg->GetSubmissionTime());
  958. case MSG_VIEW_ITEM_SEND_TIME:
  959. return m_pMsg->GetScheduleTime().Compare (
  960. other.m_pMsg->GetScheduleTime());
  961. case MSG_VIEW_ITEM_SENDER_NAME:
  962. return m_pMsg->GetSenderName().Compare (other.m_pMsg->GetSenderName());
  963. case MSG_VIEW_ITEM_SENDER_NUMBER:
  964. return m_pMsg->GetSenderNumber().Compare (other.m_pMsg->GetSenderNumber());
  965. case MSG_VIEW_ITEM_TRANSMISSION_END_TIME:
  966. return m_pMsg->GetTransmissionEndTime().Compare (
  967. other.m_pMsg->GetTransmissionEndTime());
  968. case MSG_VIEW_ITEM_TRANSMISSION_DURATION:
  969. return m_pMsg->GetTransmissionDuration().Compare (
  970. other.m_pMsg->GetTransmissionDuration());
  971. default:
  972. ASSERTION_FAILURE;
  973. return 0;
  974. }
  975. ASSERTION_FAILURE;
  976. } // CViewRow::CompareByItem