1 #include "kprogress.h"
2 #include "smapiarea.h"
3 
4 
smapiArea(char * newname,char * newpath,word mode,word type,address * newareaaddr)5 smapiArea::smapiArea(char* newname, char* newpath, word mode, word type, address* newareaaddr)
6 {
7 		debug("smapiArea::smapiArea");
8 
9     name.sprintf(newname);
10     path.sprintf(newpath);
11     char* foo = (char*) malloc(255); // *** remove this, use QString. somehow
12     strcpy(foo, path);
13 
14     harea = MsgOpenArea((unsigned char*)foo, mode, type);
15     if (harea != 0) {
16     		debug("area open");
17         areaaddress = newareaaddr;
18     } else {
19 	    	debug("area: %s", foo);
20     		fatal("msgapierr:%d", msgapierr); // *** make this nice
21 				// #define MERR_NONE   0           /* No error  */
22 				//#define MERR_BADH   1           /* Invalid handle passed to function */
23 				//#define MERR_BADF   2           /* Invalid or corrupted file */
24 				//#define MERR_NOMEM  3           /* Not enough memory for specified operation */
25 				//#define MERR_NODS   4           /* Maybe not enough disk space for operation */
26 				//#define MERR_NOENT  5           /* File/message does not exist */
27 				//#define MERR_BADA   6           /* Bad argument passed to msgapi function */
28 				//#define MERR_EOPEN  7           /* Couldn't close - messages still open */
29     }
30 }
31 
32 
33 
~smapiArea()34 smapiArea::~smapiArea()
35 {
36     MsgCloseArea(harea);
37 }
38 
39 
40 
41 
getName()42 QString smapiArea::getName()
43 {
44     return QString(name);
45 }
46 
47 
getPath()48 QString smapiArea::getPath()
49 {
50     return QString(path);
51 }
52 
53 
54 
msgNum2UmsgId(int num)55 UMSGID smapiArea::msgNum2UmsgId(int num)
56 {
57     debug("UMSGID smapiArea::MsgNum2UmsgId(int num):%d", num);
58     return MsgMsgnToUid(harea, (dword)num);
59 }
60 
61 
62 
getLastRead()63 int smapiArea::getLastRead()
64 {
65     return lastread;
66 }
67 
68 
69 
getAreaSize()70 int smapiArea::getAreaSize()
71 {
72 		if (MsgGetNumMsg(harea) != (dword)-1) {
73 		    debug("MsgGetMsgNum: %d",(int)MsgGetNumMsg(harea));
74 				return (int)MsgGetNumMsg(harea);
75 		} else {
76 				return 0;
77 		}
78 }
79 
80 
81 
getAddress()82 address *smapiArea::getAddress()
83 {
84     return areaaddress;
85 }
86 
87 
88 
getHAREA()89 HAREA smapiArea::getHAREA()
90 {
91     return harea;
92 }
93 
94 
setLastRead(UMSGID newlastread)95 void smapiArea::setLastRead(UMSGID newlastread)
96 {
97     lastread = newlastread;
98 }
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116