CAPIMethods.C 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. *+SNOTICE
  25. *
  26. * $XConsortium: CAPIMethods.C /main/4 1996/04/21 19:47:13 drk $
  27. *
  28. * RESTRICTED CONFIDENTIAL INFORMATION:
  29. *
  30. * The information in this document is subject to special
  31. * restrictions in a confidential disclosure agreement bertween
  32. * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
  33. * document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
  34. * Sun's specific written approval. This documment and all copies
  35. * and derivative works thereof must be returned or destroyed at
  36. * Sun's request.
  37. *
  38. * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
  39. *
  40. *+ENOTICE
  41. */
  42. #include <DtMail/DtMail.h>
  43. #include <DtMail/DtMail.hh>
  44. extern "C" DtMailSession
  45. DtMailCreateSession(CMEnv * error,
  46. const char * app_name)
  47. {
  48. DtMailEnv err(error);
  49. DtMail::Session * session = new DtMail::Session(err, app_name);
  50. return((DtMailSession)session);
  51. }
  52. extern "C" void
  53. DtMailCloseSession(CMEnv * error,
  54. DtMailSession session,
  55. DtMailBoolean)
  56. {
  57. DtMailEnv err(error);
  58. DtMail::Session * _session = (DtMail::Session *)session;
  59. err.clear();
  60. delete _session;
  61. }
  62. extern "C" int
  63. DtMailGetMinorCode(CMEnv * error)
  64. {
  65. DtMailEnv err(error);
  66. return(DtMail::getMinorCode(err));
  67. }
  68. extern "C" const char *
  69. DtMailGetErrorString(CMEnv * error)
  70. {
  71. DtMailEnv err(error);
  72. return(DtMail::getErrorString(err));
  73. }
  74. extern "C" const char **
  75. DtMailEnumerateImpls(DtMailSession session, CMEnv * error)
  76. {
  77. DtMailEnv err(error);
  78. DtMail::Session * _session = (DtMail::Session *)session;
  79. return(_session->enumerateImpls(err));
  80. }
  81. extern "C" void
  82. DtMailSetDefaultImpl(DtMailSession session,
  83. CMEnv * error,
  84. const char * impl)
  85. {
  86. DtMailEnv err(error);
  87. DtMail::Session * _session = (DtMail::Session *)session;
  88. _session->setDefaultImpl(err, impl);
  89. return;
  90. }
  91. extern "C" const char *
  92. DtMailGetDefaultImpl(DtMailSession session, CMEnv * error)
  93. {
  94. DtMailEnv err(error);
  95. DtMail::Session * _session = (DtMail::Session *)session;
  96. return(_session->getDefaultImpl(err));
  97. }
  98. extern "C" void
  99. DtMailQueryImpl(DtMailSession session,
  100. CMEnv * error,
  101. const char * impl,
  102. const char * capability,
  103. ...)
  104. {
  105. DtMailEnv err(error);
  106. va_list args;
  107. DtMail::Session * _session = (DtMail::Session *)session;
  108. va_start(args, capability);
  109. _session->queryImplV(err, impl, capability, args);
  110. va_end(args);
  111. }
  112. extern "C" DtMailMailBox
  113. DtMailMailBoxConstruct(DtMailSession session,
  114. CMEnv * error,
  115. DtMailObjectSpace space,
  116. void * path,
  117. DtMailCallback cb_func,
  118. void * client_data)
  119. {
  120. DtMailEnv err(error);
  121. DtMail::Session * _session = (DtMail::Session *)session;
  122. return((DtMailMailBox)_session->mailBoxConstruct(err,
  123. space,
  124. path,
  125. cb_func,
  126. client_data));
  127. }
  128. extern "C" void
  129. DtMailMailBoxDestruct(DtMailMailBox mbox)
  130. {
  131. DtMail::MailBox *mb = (DtMail::MailBox *)mbox;
  132. delete mb;
  133. }
  134. extern "C" void
  135. DtMailMailBoxCreate(DtMailMailBox mbox, CMEnv * error)
  136. {
  137. DtMailEnv err(error);
  138. DtMail::MailBox *mb = (DtMail::MailBox *)mbox;
  139. mb->create(err);
  140. }
  141. extern "C" void
  142. DtMailMailBoxOpen(DtMailMailBox mbox, CMEnv * error, DtMailBoolean auto_create)
  143. {
  144. DtMailEnv err(error);
  145. DtMail::MailBox *mb = (DtMail::MailBox *)mbox;
  146. mb->open(err, auto_create);
  147. }
  148. extern "C" DtMailMessage
  149. DtMailMailBoxGetFirstMessage(DtMailMailBox mbox, CMEnv * error)
  150. {
  151. DtMailEnv err(error);
  152. DtMail::MailBox *mb = (DtMail::MailBox *)mbox;
  153. return((DtMailMessage)mb->getFirstMessage(err));
  154. }
  155. extern "C" DtMailMessage
  156. DtMailMailBoxGetNextMessage(DtMailMailBox mbox, CMEnv * error, DtMailMessage last)
  157. {
  158. DtMailEnv err(error);
  159. DtMail::MailBox *mb = (DtMail::MailBox *)mbox;
  160. DtMail::Message *ml = (DtMail::Message *)last;
  161. return((DtMailMessage)mb->getNextMessage(err, ml));
  162. }
  163. extern "C" DtMailMessage
  164. DtMailMailBoxNewMessage(DtMailMailBox mbox, CMEnv * error)
  165. {
  166. DtMailEnv err(error);
  167. DtMail::MailBox *mb = (DtMail::MailBox *)mbox;
  168. return((DtMailMessage)mb->newMessage(err));
  169. }
  170. /*
  171. extern "C" DtMailHeaderHandle
  172. DtMailEnvelopeGetFirstHeader(DtMailEnvelope ev,
  173. CMEnv * error,
  174. char ** name,
  175. DtMailValueSeq ** value,
  176. CMBoolean translate_name)
  177. {
  178. DtMailEnv err(error);
  179. DtMail::Envelope *env = (DtMail::Envelope *)ev;
  180. return(env->getFirstHeader(*err, name, value, translate_name));
  181. }
  182. extern "C" DtMailHeaderHandle
  183. DtMailEnvelopeGetNextHeader(DtMailEnvelope ev,
  184. CMEnv * error,
  185. DtMailHeaderHandle last,
  186. char ** name,
  187. DtMailValueSeq ** value,
  188. CMBoolean translate_name)
  189. {
  190. DtMailEnv err(error);
  191. DtMail::Envelope *env = (DtMail::Envelope *)ev;
  192. return(env->getNextHeader(*err, last, name, value, translate_name));
  193. }
  194. extern "C" void
  195. DtMailEnvelopeGetHeader(DtMailEnvelope ev,
  196. CMEnv * error,
  197. const CMGlobalName name,
  198. DtMailValueSeq ** value)
  199. {
  200. DtMailEnv err(error);
  201. DtMail::Envelope *env = (DtMail::Envelope *)ev;
  202. env->getHeader(*err, name, value);
  203. }
  204. extern "C" void
  205. DtMailEnvelopeSetHeaderSeq(DtMailEnvelope ev,
  206. CMEnv * error,
  207. const CMGlobalName name,
  208. const DtMailValueSeq * value)
  209. {
  210. DtMailEnv err(error);
  211. DtMail::Envelope *env = (DtMail::Envelope *)ev;
  212. env->setHeaderSeq(*err, name, value);
  213. }
  214. extern "C" void
  215. DtMailEnvelopeSetHeader(DtMailEnvelope ev,
  216. CMEnv * error,
  217. const CMGlobalName name,
  218. const DtMailValue * value,
  219. CMBoolean replace)
  220. {
  221. DtMailEnv err(error);
  222. DtMail::Envelope *env = (DtMail::Envelope *)ev;
  223. env->setHeader(*err, name, value, replace);
  224. }
  225. extern "C" void
  226. DtMailEnvelopeTransportName(DtMailEnvelope ev,
  227. CMEnv * error,
  228. CMGlobalName name,
  229. char ** trans_name)
  230. {
  231. DtMailEnv err(error);
  232. DtMail::Envelope *env = (DtMail::Envelope *)ev;
  233. env->transportName(*err, name, trans_name);
  234. }
  235. extern "C" CMObject
  236. DtMailEnvelopeObject(DtMailEnvelope ev, CMEnv * error)
  237. {
  238. DtMailEnv err(error);
  239. DtMail::Envelope *env = (DtMail::Envelope *)ev;
  240. return(env->object(err));
  241. }
  242. extern "C" void
  243. DtMailEnvelopeDestroy(DtMailEnvelope ev)
  244. {
  245. DtMail::Envelope *env = (DtMail::Envelope *)ev;
  246. delete env;
  247. return;
  248. }
  249. extern "C" DtMailHeaderHandle
  250. DtMailBodyPartGetFirstHeader(DtMailBodyPart bp,
  251. CMEnv * error,
  252. char ** name,
  253. DtMailValueSeq ** value,
  254. CMBoolean trans)
  255. {
  256. DtMailEnv err(error);
  257. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  258. return(bpp->getFirstHeader(*err, name, value, trans));
  259. }
  260. extern "C" DtMailHeaderHandle
  261. DtMailBodyPartGetNextHeader(DtMailBodyPart bp,
  262. CMEnv * error,
  263. DtMailHeaderHandle hd,
  264. char ** name,
  265. DtMailValueSeq ** value,
  266. CMBoolean trans)
  267. {
  268. DtMailEnv err(error);
  269. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  270. return(bpp->getNextHeader(*err, hd, name, value, trans));
  271. }
  272. extern "C" void
  273. DtMailBodyPartGetHeader(DtMailBodyPart bp,
  274. CMEnv * error,
  275. const CMGlobalName name,
  276. DtMailValueSeq ** value)
  277. {
  278. DtMailEnv err(error);
  279. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  280. bpp->getHeader(*err, name, value);
  281. }
  282. extern "C" void
  283. DtMailBodyPartSetHeaderSeq(DtMailBodyPart bp,
  284. CMEnv * error,
  285. const CMGlobalName name,
  286. const DtMailValueSeq * value)
  287. {
  288. DtMailEnv err(error);
  289. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  290. bpp->setHeaderSeq(*err, name, value);
  291. }
  292. extern "C" void
  293. DtMailBodyPartSetHeader(DtMailBodyPart bp,
  294. CMEnv * error,
  295. const CMGlobalName name,
  296. const DtMailValue * value,
  297. CMBoolean replace)
  298. {
  299. DtMailEnv err(error);
  300. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  301. bpp->setHeader(*err, name, value, replace);
  302. }
  303. extern "C" void
  304. DtMailBodyPartTransportName(DtMailBodyPart bp,
  305. CMEnv * error,
  306. CMGlobalName name,
  307. char ** trans_name)
  308. {
  309. DtMailEnv err(error);
  310. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  311. bpp->transportName(*err, name, trans_name);
  312. }
  313. extern "C" CMObject
  314. DtMailBodyPartObject(DtMailBodyPart bp, CMEnv * error)
  315. {
  316. DtMailEnv err(error);
  317. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  318. return(bpp->object(err));
  319. }
  320. extern "C" CMBoolean
  321. DtMailBodyPartIsContainer(DtMailBodyPart bp, CMEnv *error)
  322. {
  323. DtMailEnv err(error);
  324. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  325. return(bpp->isContainer(err));
  326. }
  327. extern "C" DtMailMessage *
  328. DtMailBodyPartGetEmbeddedMessage(DtMailBodyPart bp, CMEnv *error)
  329. {
  330. DtMailEnv err(error);
  331. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  332. return((DtMailMessage *)bpp->getEmbeddedMessage(err));
  333. }
  334. extern "C" void
  335. DtMailBodyPartGetContents(DtMailBodyPart bp, CMEnv * error, void ** contents, unsigned long * length,
  336. CMGlobalName * type)
  337. {
  338. DtMailEnv err(error);
  339. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  340. bpp->getContents(*err, contents, *length, type);
  341. }
  342. extern "C" void
  343. DtMailBodyPartSetContents(DtMailBodyPart bp, CMEnv * error, const void * contents, const unsigned long length,
  344. const CMGlobalName type)
  345. {
  346. DtMailEnv err(error);
  347. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  348. bpp->setContents(*err, contents, length, type);
  349. }
  350. extern "C" void
  351. DtMailBodyPartDestroy(DtMailBodyPart bp)
  352. {
  353. DtMail::BodyPart *bpp = (DtMail::BodyPart *)bp;
  354. delete bpp;
  355. }
  356. extern "C" DtMailMessage
  357. DtMailFileMessageConstruct(CMEnv * error,
  358. CMSession session,
  359. const char * path,
  360. FileCallback cb_func,
  361. void * client_data)
  362. {
  363. DtMailEnv err(error);
  364. return((DtMailMessage)new DtMail::FileMessage(*err,
  365. session,
  366. path,
  367. cb_func,
  368. client_data));
  369. }
  370. extern "C" void
  371. DtMailFileMessageDestruct(DtMailMessage msg)
  372. {
  373. DtMail::FileMessage * fm = (DtMail::FileMessage *)msg;
  374. delete fm;
  375. }
  376. extern "C" CMBoolean
  377. DtMailFileMessageIsModified(DtMailMessage msg, CMEnv * error)
  378. {
  379. DtMailEnv err(error);
  380. DtMail::FileMessage * fm = (DtMail::FileMessage *)msg;
  381. return(fm->isModified(err));
  382. }
  383. extern "C" void
  384. DtMailFileMessageRequestSave(DtMailMessage msg, CMEnv * error)
  385. {
  386. DtMailEnv err(error);
  387. DtMail::FileMessage * fm = (DtMail::FileMessage *)msg;
  388. fm->requestSave(err);
  389. }
  390. extern "C" void
  391. DtMailFileMessageRequestRevert(DtMailMessage msg, CMEnv * error)
  392. {
  393. DtMailEnv err(error);
  394. DtMail::FileMessage * fm = (DtMail::FileMessage *)msg;
  395. fm->requestRevert(err);
  396. }
  397. extern "C" void
  398. DtMailFileMessageRequestOpen(DtMailMessage msg, CMEnv * error)
  399. {
  400. DtMailEnv err(error);
  401. DtMail::FileMessage * fm = (DtMail::FileMessage *)msg;
  402. fm->requestOpen(err);
  403. }
  404. extern "C" void
  405. DtMailFileMessageCreate(DtMailMessage msg, CMEnv * error)
  406. {
  407. DtMailEnv err(error);
  408. DtMail::FileMessage * fm = (DtMail::FileMessage *)msg;
  409. fm->create(err);
  410. }
  411. extern "C" void
  412. DtMailFileMessageOpen(DtMailMessage msg, CMEnv * error, CMBoolean auto_create)
  413. {
  414. DtMailEnv err(error);
  415. DtMail::FileMessage * fm = (DtMail::FileMessage *)msg;
  416. fm->open(*err, auto_create);
  417. }
  418. extern "C" DtMailMessage
  419. DtMailEmbeddedMessageCreate(CMEnv * error, DtMailMailBox owner)
  420. {
  421. DtMailEnv err(error);
  422. DtMail::MailBox * mb = (DtMail::MailBox *)owner;
  423. return((DtMailMessage)new DtMail::EmbeddedMessage(*err, *mb));
  424. }
  425. extern "C" void
  426. DtMailEmbeddedMessageDestroy(DtMailMessage msg)
  427. {
  428. DtMailEnv err(error);
  429. DtMail::EmbeddedMessage * em = (DtMail::EmbeddedMessage *)msg;
  430. delete em;
  431. }
  432. extern "C" DtMailEnvelope
  433. DtMailMessageGetEnvelope(DtMailMessage bmm, CMEnv * error)
  434. {
  435. DtMailEnv err(error);
  436. DtMail::Message * msg = (DtMail::Message *)bmm;
  437. return((DtMailEnvelope)msg->getEnvelope(err));
  438. }
  439. extern "C" int
  440. DtMailMessageGetBodyCount(DtMailMessage bmm, CMEnv * error)
  441. {
  442. DtMailEnv err(error);
  443. DtMail::Message * msg = (DtMail::Message *)bmm;
  444. return(msg->getBodyCount(err));
  445. }
  446. extern "C" DtMailBodyPart *
  447. DtMailMessageGetFirstBodyPart(DtMailMessage bmm, CMEnv * error)
  448. {
  449. DtMailEnv err(error);
  450. DtMail::Message * msg = (DtMail::Message *)bmm;
  451. return((DtMailBodyPart *)msg->getFirstBodyPart(err));
  452. }
  453. extern "C" DtMailBodyPart *
  454. DtMailMessageGetNextBodyPart(DtMailMessage bmm, CMEnv * error, DtMailBodyPart * bml)
  455. {
  456. DtMailEnv err(error);
  457. DtMail::Message * msg = (DtMail::Message *)bmm;
  458. DtMail::BodyPart * last = (DtMail::BodyPart *)bml;
  459. return((DtMailBodyPart *)msg->getNextBodyPart(*err, last));
  460. }
  461. extern "C" DtMailBodyPart *
  462. DtMailMessageNewBodyPart(DtMailMessage bmm, CMEnv * error)
  463. {
  464. DtMailEnv err(error);
  465. DtMail::Message * msg = (DtMail::Message *)bmm;
  466. return((DtMailBodyPart *)msg->newBodyPart(err));
  467. }
  468. extern "C" CMContainer
  469. DtMailMessageContainer(DtMailMessage bmm, CMEnv * error)
  470. {
  471. DtMailEnv err(error);
  472. DtMail::Message * msg = (DtMail::Message *)bmm;
  473. return(msg->message(err));
  474. }
  475. */