wmail: fixed some typo's.
[dockapps.git] / wmcapshare / wmcapshare.c
blob2d4f8e74525fe846f91f972f1ddd626ef84ab72e
1 /*********************************************************************
3 * Filename: wmcapshare.c
4 * Version: 0.1
5 * Description: Window Maker Dockapp to Control HP Capshare
6 * Status: Development
7 * Author: Ben Moore <ben@netjunki.org>
8 * Created at: Sun Oct 06 10:00:00 2001
9 * Modified at: Sun Oct 06 10:00:00 2001
10 * Modified by: Ben Moore <ben@netjunki.org>
12 * Copyright (c) 2001 Ben Moore, All Rights Reserved.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * MA 02111-1307 USA
31 * Start with --help to see available options
32 * By default captured pages are put in /tmp
34 ********************************************************************/
36 #include <stdio.h>
38 #ifndef _WIN32
39 #include <unistd.h>
40 #endif
42 #include <openobex/obex.h>
43 #include "obex_put_common.h"
44 #include "obex_io.h"
46 #include <libdockapp/dockapp.h>
47 #include "xpm/base.xpm"
48 #include "xpm/tstatfld.xpm"
49 #include "xpm/capshare.xpm"
50 #include "xpm/connected.xpm"
51 #include "xpm/disconnected.xpm"
52 #include "xpm/transfering.xpm"
53 #include "xpm/lcdchars2.xpm"
54 #include "xpm/lcdnums.xpm"
55 #include "xpm/plane00.xpm"
56 #include "xpm/plane01.xpm"
57 #include "xpm/plane02.xpm"
58 #include "xpm/plane03.xpm"
59 #include "xpm/plane04.xpm"
60 #include "xpm/plane05.xpm"
61 #include "xpm/plane06.xpm"
62 #include "xpm/plane07.xpm"
63 #include "xpm/plane08.xpm"
64 #include "xpm/plane09.xpm"
65 #include "xpm/plane10.xpm"
66 #include "xpm/plane11.xpm"
67 #include "xpm/plane12.xpm"
68 #include "xpm/plane13.xpm"
69 #include "xpm/plane14.xpm"
70 #include "xpm/plane15.xpm"
71 #include "xpm/plane16.xpm"
72 #include "xpm/plane17.xpm"
73 #include "xpm/plane18.xpm"
74 #include "xpm/plane19.xpm"
76 #include "wmcapshare.h"
77 #include "version.h"
79 char *displayName = "";
80 gchar *savedir = "/tmp/";
81 GC gc;
82 Pixmap pixmap, mask;
83 Pixmap tstatfld_buf, tstatfld_mask;
84 Pixmap blank_buf, blank_mask;
85 Pixmap capshare_pic, capshare_mask;
86 Pixmap plane_anim[20], plane_animmask[20];
87 Pixmap connect_pic, connect_mask;
88 Pixmap disconnect_pic, disconnect_mask;
89 Pixmap transfer_pic, transfer_mask;
90 Pixmap char_buf, char_mask;
91 Pixmap num_buf, num_mask;
93 obex_t *handle = NULL;
94 volatile int finished = FALSE;
95 volatile int state = 0;
96 int planeanimpos = 0;
98 static DAProgramOption options[] = {
99 {"-d", "--dir", "Directory to save to", DOString, False, {&savedir}}
105 int charpos(char c) {
106 int cn, cai;
107 cn = c - 97;
108 cai = cn*6;
109 return cai;
112 int string2pixmap(char* str, Pixmap *p) {
113 int x;
114 XCopyArea(DADisplay, blank_buf, *p, gc, 0,0, 42, 8, 0, 0);
115 for (x = 0; x < strlen(str); x++) {
116 XCopyArea(DADisplay, char_buf, *p, gc, charpos(str[x]),0, 6, 8, x*6, 0);
121 void updateDisplay() {
122 switch(state) {
123 case CAP_WAIT: /* wait */
124 planeanimpos=0;
125 XCopyArea(DADisplay, capshare_pic, pixmap, gc, 0, 0, 60, 29, 0, 15);
126 XCopyArea(DADisplay, disconnect_pic, pixmap, gc, 0, 0, 14, 15, 0, 45);
127 string2pixmap("waiting", &tstatfld_buf);
128 XCopyArea(DADisplay, tstatfld_buf, pixmap, gc, 0, 0, 42, 8, 16, 48);
129 DASetPixmap(pixmap);
130 break;
131 case CAP_RECIEVE: /* recieve */
132 XCopyArea(DADisplay, plane_anim[planeanimpos], pixmap, gc, 0, 0, 60, 29, 0, 15);
133 planeanimpos++;
134 if(planeanimpos==20)
135 planeanimpos = 0;
136 XCopyArea(DADisplay, connect_pic, pixmap, gc, 0, 0, 14, 15, 0, 45);
137 string2pixmap("recieve", &tstatfld_buf);
138 XCopyArea(DADisplay, tstatfld_buf, pixmap, gc, 0, 0, 42, 8, 16, 48);
139 DASetPixmap(pixmap);
140 break;
141 case CAP_CONNECT:
142 /* connect */
143 XCopyArea(DADisplay, disconnect_pic, pixmap, gc, 0, 0, 14, 15, 0, 45);
144 string2pixmap("connect", &tstatfld_buf);
145 XCopyArea(DADisplay, tstatfld_buf, pixmap, gc, 0, 0, 42, 8, 16, 48);
146 DASetPixmap(pixmap);
147 break;
154 * Function main (argc, )
156 * Starts all the fun!
159 int main(int argc, char *argv[])
161 obex_object_t *object;
162 int ret;
163 unsigned height,width;
164 int i;
166 DAParseArguments(argc, argv, options,
167 sizeof(options)/sizeof(DAProgramOption),
168 "CapShare Document Management Dock Applet\nBen Moore ben@netjunki.org\n",
169 VERSION);
172 DAInitialize(displayName, "wmcapshare", 60,60, argc, argv);
173 DAMakePixmapFromData(lcdchars2_xpm, &char_buf, &char_mask, &height, &width);
174 DAMakePixmapFromData(lcdnums_xpm, &num_buf, &num_mask, &height, &width);
175 DAMakePixmapFromData(base_xpm, &pixmap, &mask, &height, &width);
176 DAMakePixmapFromData(tstatfld_xpm, &tstatfld_buf, &tstatfld_mask, &height, &width);
177 DAMakePixmapFromData(tstatfld_xpm, &blank_buf, &blank_mask, &height, &width);
178 DAMakePixmapFromData(capshare_xpm, &capshare_pic, &capshare_mask, &height, &width);
179 DAMakePixmapFromData(transfering_xpm, &transfer_pic, &transfer_mask, &height, &width);
180 DAMakePixmapFromData(connected_xpm, &connect_pic, &connect_mask, &height, &width);
181 DAMakePixmapFromData(disconnected_xpm, &disconnect_pic, &disconnect_mask, &height, &width);
182 DAMakePixmapFromData( plane00_xpm, &plane_anim[0], &plane_animmask[1], &height, &width);
183 DAMakePixmapFromData( plane01_xpm, &plane_anim[1], &plane_animmask[2], &height, &width);
184 DAMakePixmapFromData( plane02_xpm, &plane_anim[2], &plane_animmask[3], &height, &width);
185 DAMakePixmapFromData( plane03_xpm, &plane_anim[3], &plane_animmask[4], &height, &width);
186 DAMakePixmapFromData( plane04_xpm, &plane_anim[4], &plane_animmask[5], &height, &width);
187 DAMakePixmapFromData( plane05_xpm, &plane_anim[5], &plane_animmask[6], &height, &width);
188 DAMakePixmapFromData( plane06_xpm, &plane_anim[6], &plane_animmask[6], &height, &width);
189 DAMakePixmapFromData( plane07_xpm, &plane_anim[7], &plane_animmask[7], &height, &width);
190 DAMakePixmapFromData( plane08_xpm, &plane_anim[8], &plane_animmask[8], &height, &width);
191 DAMakePixmapFromData( plane09_xpm, &plane_anim[9], &plane_animmask[9], &height, &width);
192 DAMakePixmapFromData( plane10_xpm, &plane_anim[10], &plane_animmask[10], &height, &width);
193 DAMakePixmapFromData( plane11_xpm, &plane_anim[11], &plane_animmask[11], &height, &width);
194 DAMakePixmapFromData( plane12_xpm, &plane_anim[12], &plane_animmask[12], &height, &width);
195 DAMakePixmapFromData( plane13_xpm, &plane_anim[13], &plane_animmask[13], &height, &width);
196 DAMakePixmapFromData( plane14_xpm, &plane_anim[14], &plane_animmask[14], &height, &width);
197 DAMakePixmapFromData( plane15_xpm, &plane_anim[15], &plane_animmask[15], &height, &width);
198 DAMakePixmapFromData( plane16_xpm, &plane_anim[16], &plane_animmask[16], &height, &width);
199 DAMakePixmapFromData( plane17_xpm, &plane_anim[17], &plane_animmask[17], &height, &width);
200 DAMakePixmapFromData( plane18_xpm, &plane_anim[18], &plane_animmask[18], &height, &width);
201 DAMakePixmapFromData( plane19_xpm, &plane_anim[19], &plane_animmask[19], &height, &width);
203 gc = DefaultGC(DADisplay, DefaultScreen(DADisplay));
207 string2pixmap("recieve", &tstatfld_buf);
208 XCopyArea(DADisplay, plane_pic, pixmap, gc, 0, 0, 60, 29, 0, 15);
209 XCopyArea(DADisplay, tstatfld_buf, pixmap, gc, 0, 0, 42, 8, 16, 48);
210 DASetPixmap(pixmap);
211 XCopyArea(DADisplay, connect_pic, pixmap, gc, 0, 0, 14, 15, 0, 45);
212 DASetPixmap(pixmap);
215 XCopyArea(DADisplay, capshare_pic, pixmap, gc, 0, 0, 60, 29, 0, 15);
216 DAShow();
218 while(1) {
219 handle = OBEX_Init(OBEX_TRANS_IRDA, obex_event, 0);
221 printf("Waiting for files\n");
222 OBEX_ServerRegister(handle, "OBEX");
224 while (!finished) {
225 updateDisplay();
226 OBEX_HandleInput(handle, 1);
229 finished = FALSE;
232 return 0;