UserDialog.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. /******************************************************************************
  2. |* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. |* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. |* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. |* PARTICULAR PURPOSE.
  6. |*
  7. |* Copyright 1995-2004 Ahead Software AG. All Rights Reserved.
  8. |*-----------------------------------------------------------------------------
  9. |* NeroSDK / NeroCmd
  10. |*
  11. |* PROGRAM: UserDialog.cpp
  12. |*
  13. |* PURPOSE: Interaction with the user
  14. ******************************************************************************/
  15. #include "stdafx.h"
  16. #include "BurnCore.h"
  17. //#include "Response.h"
  18. // IMPORTANT: Unimplemented DLG_ROBO_xxx messages !!!
  19. //
  20. NeroUserDlgInOut NERO_CALLBACK_ATTR CWriteToDVD::UserDialog (void* pUserData, NeroUserDlgInOut type, void *data)
  21. {
  22. //_ASSERTE (pUserData != NULL);
  23. //CBurnContext * pBurnContext = (CBurnContext*)pUserData;
  24. //const bool bUserInteraction = pBurnContext->m_params->GetUserInteraction ();
  25. //printf ("\r \r");
  26. //switch (type)
  27. //{
  28. // case DLG_AUTO_INSERT:
  29. // {
  30. // static const CResponsePairs mapping[] =
  31. // {
  32. // "Install drivers & restart", DLG_RETURN_INSTALL_DRIVER,
  33. // "Turn off & restart", DLG_RETURN_OFF_RESTART,
  34. // "Exit", DLG_RETURN_EXIT,
  35. // "Continue at own risk", DLG_RETURN_CONTINUE,
  36. // NULL
  37. // };
  38. // puts ("Auto Insert Notification is turned on in the system configuration.\n"
  39. // "This may cause serious problems while burning: your CD might be damaged,\n"
  40. // "or the system might hang up.\n"
  41. // "\n"
  42. // "Nero is able to burn CDs with Auto Insert Notification turned on if all\n"
  43. // "necessary drivers are installed.\n"
  44. // "\n"
  45. // "You can do the following:\n"
  46. // "Install drivers and restart Windows\n"
  47. // "Turn off Auto Insert Notification and restart Windows\n"
  48. // "Exit Nero\n"
  49. // "Continue at your own risk\n");
  50. // CResponse response (mapping, 2);
  51. // return response;
  52. // }
  53. // case DLG_DISCONNECT_RESTART:
  54. // case DLG_DISCONNECT:
  55. // {
  56. // puts ("Disconnect is turned off in the system configuration.\n"
  57. // "This may cause serious problems while burning: your CD\n"
  58. // "might be damaged, or the system might hang up.\n");
  59. //
  60. // if (DLG_DISCONNECT_RESTART == type)
  61. // {
  62. // static const CResponsePairs mapping[] =
  63. // {
  64. // "Turn on & restart", DLG_RETURN_ON_RESTART,
  65. // "Don't turn on & restart\n", DLG_RETURN_RESTART,
  66. // NULL
  67. // };
  68. // CResponse response (mapping, 0);
  69. // return response;
  70. // }
  71. // else
  72. // {
  73. // static const CResponsePairs mapping[] =
  74. // {
  75. // "Turn on & restart", DLG_RETURN_ON_RESTART,
  76. // "Don't turn on & restart", DLG_RETURN_RESTART,
  77. // "Continue at own risk", DLG_RETURN_CONTINUE,
  78. // NULL
  79. // };
  80. // CResponse response (mapping, 0);
  81. // return response;
  82. // }
  83. // }
  84. // case DLG_AUTO_INSERT_RESTART:
  85. // {
  86. // puts ("Auto Insert Notification is now OFF. You should restart Windows.\n");
  87. // CResponseOkay response;
  88. // return response;
  89. // }
  90. // case DLG_RESTART:
  91. // {
  92. // puts ("Please restart Windows now.\n");
  93. // CResponseOkay response;
  94. //
  95. // return response;
  96. // }
  97. // case DLG_SETTINGS_RESTART:
  98. // {
  99. // static const CResponsePairs mapping[] =
  100. // {
  101. // "Restart", DLG_RETURN_RESTART,
  102. // "Continue at own risk", DLG_RETURN_CONTINUE,
  103. // NULL
  104. // };
  105. //
  106. // puts ("Nero detected some modifications of your PC system configuration\n"
  107. // "and needs to modify some settings. Please restart your PC to make\n"
  108. // "the changes become effective.\n");
  109. // CResponse response (mapping, 0);
  110. //
  111. // return response;
  112. // }
  113. // case DLG_OVERBURN:
  114. // {
  115. // puts ("Sorry, this compilation contains too much data to fit on the CD\n"
  116. // "with respect to the normal CD capacity. Do you want to try\n"
  117. // "overburn writing at your own risk (this might cause read\n"
  118. // "errors at the end of the CD or might even damage your recorder)?\n\n"
  119. // "Note: It is also possible, that SCSI/Atapi errors occur at the end\n"
  120. // "of the simulation or burning. Even in this case there is a certain\n"
  121. // "chance, that the CD is readable.\n");
  122. // const DLG_OVERBURN_INFO * pInfo = (const DLG_OVERBURN_INFO *) data;
  123. // _ASSERTE (pInfo != NULL);
  124. // printf ("Total blocks to be written: %d\n", pInfo->dwTotalBlocksOnCD);
  125. // printf ("Free capacity in blocks: %d\n", pInfo->dwTotalCapacity);
  126. // CResponseYesNoDefaultIsYes response;
  127. //
  128. // return response;
  129. // }
  130. // case DLG_COPY_QUALITY_LOSS:
  131. // {
  132. // puts( "Disc must be written as 'track at once' ('disc at once' not\n"
  133. // "supported or not able to write such a disc). This means\n"
  134. // "there might be some minor quality loss (e.g. lost audio index\n"
  135. // "or different pause between audio tracks). Do you want to\n"
  136. // "proceed anyway?\n");
  137. // CResponseYesNoDefaultIsYes response;
  138. //
  139. // return response;
  140. // }
  141. //
  142. // case DLG_COPY_FULLRISK:
  143. // {
  144. // puts( "Disc must be written as 'track at once' ('disc at once' not\n"
  145. // "supported or not able to write such a disc). Unfortunately\n"
  146. // "your image has a special format which can most likely only\n"
  147. // "be written correctly with 'disc at once'. But you may\n"
  148. // "PROCEED AT YOUR OWN RISK. Do you want to continue\n"
  149. // "burning?\n");
  150. // CResponseYesNoDefaultIsYes response;
  151. //
  152. // return response;
  153. // }
  154. // case DLG_AUDIO_PROBLEMS:
  155. // {
  156. // if (((DWORD)data) & AUP_NOTRACK_FOUND)
  157. // {
  158. // puts ("No tracks given.");
  159. // return DLG_RETURN_EXIT;
  160. // }
  161. // if (((DWORD)data) == AUP_MEGA_FATAL)
  162. // {
  163. // puts ("fatal internal problem");
  164. // return DLG_RETURN_EXIT;
  165. // }
  166. //
  167. // puts ("Nero has detected that the following audio properties are not\n"
  168. // "supported by your recorder in the current write mode and need\n"
  169. // "to be modified:");
  170. // if (((DWORD)data) & AUP_FIRST_TR_PAUSE) puts ("- CD specification allows only 2-3 Seconds pause for the first track");
  171. // if (((DWORD)data) & AUP_PAUSE_SETTINGS) puts ("- Pause length between the tracks not supported");
  172. // if (((DWORD)data) & AUP_INDEX_SETTINGS) puts ("- Additional index positions not supported");
  173. // if (((DWORD)data) & AUP_ISRC_SETTINGS) puts ("- ISRC codes not supported");
  174. // if (((DWORD)data) & AUP_COPYPROT_SETTINGS) puts ("- Copy protection bit not supported");
  175. //
  176. // puts ("Nero can change the audio track settings for you to fit the\n"
  177. // "capabilities of your recorder. This might cause some audio\n"
  178. // "properties to be lost. Do you want Nero to change the track\n"
  179. // "settings for you?\n");
  180. // CResponseYesNoDefaultIsYes response;
  181. //
  182. // return response;
  183. // }
  184. //
  185. // case DLG_WAITCD:
  186. // {
  187. // NERO_WAITCD_TYPE waitcdType = (NERO_WAITCD_TYPE) (int)data;
  188. // LPCSTR psText = NeroGetLocalizedWaitCDTexts (waitcdType);
  189. // if (psText != NULL)
  190. // {
  191. // printf("\n%s\n", psText);
  192. // NeroFreeMem ((void *) psText);
  193. // }
  194. // if (!bUserInteraction &&
  195. // waitcdType != NERO_WAITCD_AUTOEJECTLOAD &&
  196. // waitcdType != NERO_WAITCD_WAITING)
  197. // {
  198. // // If there is supposed to be no user interaction,
  199. // // wait cd dialog would never be dismissed. Abort the
  200. // // burning process immediatelly (but only if waitcd
  201. // // type actually designates some user interaction).
  202. // //
  203. // pBurnContext->s_bAborted = true;
  204. // pBurnContext->m_bPrintUserInteractionErrorMessage = true;
  205. // }
  206. // }
  207. // break;
  208. // case DLG_WAITCD_REMINDER:
  209. // printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\b");
  210. // break;
  211. // case DLG_WAITCD_DONE:
  212. // // nothing to be done in the text interface,
  213. // // should close dialog box in a GUI
  214. // break;
  215. // case DLG_FILESEL_IMAGE:
  216. // {
  217. // printf ("Enter file name to save image to: ");
  218. // LPCSTR psImageFilename = pBurnContext->m_params->GetOutputImageFileName ();
  219. // // Check if the image filename was supplied at command
  220. // // line.
  221. // //
  222. // if (NULL == psImageFilename)
  223. // {
  224. // if (!bUserInteraction)
  225. // {
  226. // // If there should be no user interaction, fail! We need
  227. // // this filename and this can't be supplied automatically.
  228. // //
  229. // printf ("<nothing specified>\n");
  230. // pBurnContext->m_bPrintUserInteractionErrorMessage = true;
  231. // return DLG_RETURN_EXIT;
  232. // }
  233. // else
  234. // {
  235. // fgets ((char *) data, 255, stdin);
  236. // // Remove the carriage return
  237. // ((char *)data)[strlen((char *)data)-1]=0;
  238. // }
  239. // }
  240. // else
  241. // {
  242. // // First clear the supplied buffer.
  243. // //
  244. // memset (data, 0, 256);
  245. //
  246. // // Then copy at most 255 characters.
  247. // //
  248. // strncpy ((char *) data, psImageFilename, 255);
  249. // puts ((char *) data);
  250. // }
  251. // return DLG_RETURN_TRUE;
  252. // }
  253. // case DLG_BURNIMAGE_CANCEL:
  254. // printf("There is not enough space available to burn the image.\n");
  255. // break;
  256. // case DLG_NON_EMPTY_CDRW:
  257. // {
  258. // static const CResponsePairs mapping[] =
  259. // {
  260. // "Erase disc", DLG_RETURN_CONTINUE,
  261. // "Eject disc", DLG_RETURN_RESTART,
  262. // "Cancel", DLG_RETURN_EXIT,
  263. // NULL
  264. // };
  265. // NeroUserDlgInOut res;
  266. // puts ("This disc is not empty.");
  267. // // Do not ask the user if the --force_erase_cdrw
  268. // // command line parameter has been provided
  269. // // pUserData holds a pointer to CBurnContext which we set
  270. // // when initializing NeroAPI.
  271. // // We need this pointer to obtain settings and handles
  272. // // from the CBurnContext class.
  273. // if (((CBurnContext*)pUserData)->m_params->GetForceEraseCDRW())
  274. // {
  275. // res = DLG_RETURN_CONTINUE;
  276. // }
  277. // else
  278. // {
  279. // CResponse response (mapping, 2);
  280. // res = response;
  281. // }
  282. // if (DLG_RETURN_CONTINUE == res)
  283. // {
  284. // // Erase the disc
  285. // NEROAPI_CDRW_ERASE_MODE mode = NEROAPI_ERASE_QUICK;
  286. // int time = NeroGetCDRWErasingTime(((CBurnContext*)pUserData)->m_NeroDeviceHandle,mode);
  287. // // If time is negative, it means error.
  288. // //
  289. // switch (time)
  290. // {
  291. // case -1:
  292. // puts("No disc inserted!");
  293. // res = DLG_RETURN_RESTART;
  294. // break;
  295. // case -2:
  296. // puts("This recorder does not support rewritable discs!");
  297. // res = DLG_RETURN_EXIT;
  298. // break;
  299. // case -3:
  300. // puts ("The inserted disc is NOT rewritable!");
  301. // res = DLG_RETURN_RESTART;
  302. // break;
  303. // default:
  304. // if (time < 0)
  305. // {
  306. // // If this is some unknown error (negative value)
  307. // // we should print generic error message and not
  308. // // even attepmt erasing.
  309. // //
  310. // puts ("Unknown error while trying to erase disc!");
  311. // }
  312. // else
  313. // {
  314. // // If the value is positive, it is the approximate
  315. // // second count the process will take.
  316. // //
  317. // printf("Erasing disc. This will take %d seconds.\n",time);
  318. //
  319. // int err = NeroEraseDisc (((CBurnContext*)pUserData)->m_NeroDeviceHandle, mode, 0, NULL);
  320. // if (err)
  321. // {
  322. // puts("Error erasing the disc");
  323. // // There was an error erasing the disc so quit.
  324. // //
  325. // res = DLG_RETURN_EXIT;
  326. // }
  327. // }
  328. // }
  329. // }
  330. // if (res == DLG_RETURN_CONTINUE ||
  331. // res == DLG_RETURN_RESTART)
  332. // {
  333. // // If aborted flag was set in DLG_WAITCD, reset it here
  334. // // because we have successfully erased/ejected a rewritable
  335. // // disc and the process can now continue. Idle callback
  336. // // obviously hasn't yet been called at this point so
  337. // // playing with the aborted flag had no influence on NeroAPI.
  338. // //
  339. // pBurnContext->s_bAborted = false;
  340. // pBurnContext->m_bPrintUserInteractionErrorMessage = false;
  341. // }
  342. // return res;
  343. // }
  344. // case DLG_WAITCD_MEDIA_INFO:
  345. // {
  346. // const NERO_DLG_WAITCD_MEDIA_INFO * pMediaInfo = (const NERO_DLG_WAITCD_MEDIA_INFO *) data;
  347. // printf ("Last detected media: %s\n", pMediaInfo->ndwmiLastDetectedMediaName);
  348. // printf ("Requested media: %s\n", pMediaInfo->ndwmiRequestedMediaName);
  349. // // The return value is ignored.
  350. // //
  351. // }
  352. // break;
  353. // case DLG_COMP_REC_CONFLICT:
  354. // puts ("The compilation cannot be written on this recorder! "
  355. // "You should modify your compilation settings or burn "
  356. // "the disc on another recorder, that supports the required medium type.");
  357. // break;
  358. // case DLG_WRONG_MEDIUM:
  359. // puts ("Another type of medium must be used to burn this compilation!");
  360. // break;
  361. // case DLG_MESSAGEBOX:
  362. // {
  363. // const NERODLG_MESSAGEBOX * pMsgBox = (const NERODLG_MESSAGEBOX *) data;
  364. // _ASSERTE (pMsgBox != NULL);
  365. // if (pMsgBox != NULL)
  366. // {
  367. // // Construct a generic reponse according to the parameters
  368. // // passed.
  369. // //
  370. // CResponseGeneric response (pMsgBox->type, pMsgBox->defaultReturn);
  371. // // If data was interpreted correctly, proceed. If not, the
  372. // // default handling will take place.
  373. // //
  374. // if (response.IsOk ())
  375. // {
  376. // // Translate the icon type into a character.
  377. // //
  378. // char chIcon;
  379. // switch (pMsgBox->icon)
  380. // {
  381. // case NDIT_INFO:
  382. // chIcon = 'i';
  383. // break;
  384. // case NDIT_WARNING:
  385. // chIcon = '!';
  386. // break;
  387. // case NDIT_QUESTION:
  388. // chIcon = '?';
  389. // break;
  390. // case NDIT_ERROR:
  391. // default:
  392. // chIcon = 'E';
  393. // }
  394. // // Print the message and ask for a response.
  395. // //
  396. // printf ("[%c] %s\n", chIcon, pMsgBox->message);
  397. // return response;
  398. // }
  399. // }
  400. // }
  401. // break;
  402. //}
  403. return DLG_RETURN_NOT_HANDLED;
  404. }