1 | #include "../../titan/struct.h" |
---|
2 | #include "../../titan/debug.h" |
---|
3 | #include "../../titan/header.h" |
---|
4 | |
---|
5 | char pluginname[] = "MultiImage"; |
---|
6 | char plugindesc[] = "Start Images from USB device"; |
---|
7 | char pluginpic[] = "%pluginpath%/multiimage/MultiImage.png"; |
---|
8 | |
---|
9 | int pluginaktiv = 0; |
---|
10 | //int pluginversion = PLUGINVERSION; |
---|
11 | int pluginversion = 999999; |
---|
12 | |
---|
13 | char* imagepath = NULL; |
---|
14 | |
---|
15 | struct stimerthread* Multi_Image_thread = NULL; |
---|
16 | |
---|
17 | char* get_dir(char* path) |
---|
18 | { |
---|
19 | struct dirent* dirzeiger; |
---|
20 | char* dirall = NULL; |
---|
21 | DIR *dir = opendir(path); |
---|
22 | if (dir != 0) |
---|
23 | { |
---|
24 | struct dirent* dirzeiger; |
---|
25 | while(0 != (dirzeiger = readdir(dir))) |
---|
26 | { |
---|
27 | if(dirzeiger->d_name[0] != '.') |
---|
28 | { |
---|
29 | dirall = ostrcat(dirall, dirzeiger->d_name, 1, 0); |
---|
30 | dirall = ostrcat(dirall, " \n", 1, 0); |
---|
31 | } |
---|
32 | } |
---|
33 | closedir(dir); |
---|
34 | } |
---|
35 | return dirall; |
---|
36 | } |
---|
37 | |
---|
38 | void multiimage_thread() |
---|
39 | { |
---|
40 | char* cmd = NULL; |
---|
41 | while (Multi_Image_thread->aktion != STOP) |
---|
42 | { |
---|
43 | sleep(3); |
---|
44 | if(file_exist("/tmp/multiende") == 1) |
---|
45 | { |
---|
46 | textbox(_("Message"), _("INFO\nImage extracted"), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 500, 200, 0, 0); |
---|
47 | remove("/tmp/multiende"); |
---|
48 | break; |
---|
49 | } |
---|
50 | } |
---|
51 | if(Multi_Image_thread->aktion == STOP) |
---|
52 | { |
---|
53 | system("killall multi_unpack.sh"); |
---|
54 | system("killall ubireader_extract_files"); |
---|
55 | cmd = ostrcat("rm -r ",imagepath, 0, 0); |
---|
56 | system(cmd); |
---|
57 | free(cmd); cmd = NULL; |
---|
58 | |
---|
59 | } |
---|
60 | else |
---|
61 | { |
---|
62 | if(status.extplugin != NULL) |
---|
63 | { |
---|
64 | free(status.extplugin); |
---|
65 | status.extplugin = NULL; |
---|
66 | } |
---|
67 | //Aufruf des plugins |
---|
68 | status.extplugin = ostrcat("MultiImage", NULL, 0, 0); |
---|
69 | writerc(getrcconfigint("rcexit", NULL)); |
---|
70 | } |
---|
71 | free(imagepath); imagepath=NULL; |
---|
72 | Multi_Image_thread = NULL; |
---|
73 | } |
---|
74 | |
---|
75 | |
---|
76 | char* find_multiimage_dev() |
---|
77 | { |
---|
78 | char* mdev = NULL; |
---|
79 | char* path = NULL; |
---|
80 | |
---|
81 | char* pos = NULL; |
---|
82 | FILE* fd = NULL; |
---|
83 | char* fileline = NULL; |
---|
84 | fd = fopen("/proc/partitions", "r"); |
---|
85 | if(fd == NULL) |
---|
86 | { |
---|
87 | err("open /proc/partitions"); |
---|
88 | return NULL; |
---|
89 | } |
---|
90 | fileline = malloc(MINMALLOC); |
---|
91 | if(fileline == NULL) |
---|
92 | { |
---|
93 | err("no mem"); |
---|
94 | return NULL; |
---|
95 | } |
---|
96 | while(fgets(fileline, MINMALLOC, fd) != NULL) |
---|
97 | { |
---|
98 | pos = ostrstr(fileline, "sd"); |
---|
99 | if(pos != NULL) |
---|
100 | { |
---|
101 | pos = string_newline(pos); |
---|
102 | if(strlen(pos) == 4) |
---|
103 | { |
---|
104 | path = getconfig("mountpath", NULL); |
---|
105 | path = ostrcat(path, "/", 0, 0); |
---|
106 | path = ostrcat(path, pos, 1, 0); |
---|
107 | path = ostrcat(path, "/", 1, 0); |
---|
108 | path = ostrcat(path, "titan_multi", 1, 0); |
---|
109 | if(file_exist(path) == 1) |
---|
110 | { |
---|
111 | mdev = ostrcat(mdev, pos, 1, 0); |
---|
112 | } |
---|
113 | free(path); path = NULL; |
---|
114 | } |
---|
115 | } |
---|
116 | if(mdev != NULL) |
---|
117 | break; |
---|
118 | } |
---|
119 | free(fileline); |
---|
120 | fclose(fd); |
---|
121 | |
---|
122 | return mdev; |
---|
123 | } |
---|
124 | |
---|
125 | |
---|
126 | int no_mdev() |
---|
127 | { |
---|
128 | char* mdev = NULL; |
---|
129 | char* path = NULL; |
---|
130 | char* dirall = NULL; |
---|
131 | char* cmd = NULL; |
---|
132 | struct skin* tmp = NULL; |
---|
133 | int ret = 0; |
---|
134 | int rcret = 0; |
---|
135 | int ren = 0; |
---|
136 | |
---|
137 | struct skin* multipart = getscreen("multipart"); |
---|
138 | struct skin* listbox = getscreennode(multipart, "listbox"); |
---|
139 | struct skin* device = getscreennode(multipart, "device"); |
---|
140 | struct skin* text2 = getscreennode(multipart, "textbox2"); |
---|
141 | |
---|
142 | char* pos = NULL; |
---|
143 | FILE* fd = NULL; |
---|
144 | char* fileline = NULL; |
---|
145 | fd = fopen("/proc/partitions", "r"); |
---|
146 | if(fd == NULL) |
---|
147 | { |
---|
148 | err("open /proc/partitions"); |
---|
149 | return 1; |
---|
150 | } |
---|
151 | fileline = malloc(MINMALLOC); |
---|
152 | if(fileline == NULL) |
---|
153 | { |
---|
154 | err("no mem"); |
---|
155 | return 1; |
---|
156 | } |
---|
157 | while(fgets(fileline, MINMALLOC, fd) != NULL) |
---|
158 | { |
---|
159 | pos = ostrstr(fileline, "sd"); |
---|
160 | if(pos != NULL) |
---|
161 | { |
---|
162 | pos = string_newline(pos); |
---|
163 | if(strlen(pos) == 4) |
---|
164 | { |
---|
165 | if(mdev == NULL) |
---|
166 | mdev = ostrcat(mdev, pos, 1, 0); |
---|
167 | addchoicebox(device, pos, pos); |
---|
168 | } |
---|
169 | } |
---|
170 | } |
---|
171 | free(fileline); |
---|
172 | fclose(fd); |
---|
173 | if(mdev == NULL) |
---|
174 | { |
---|
175 | textbox("MultiImage", _("No device available"), _("OK"), getrcconfigint("rcok", NULL),NULL, 0, NULL, 0, NULL, 0, 500, 200, 0, 0); |
---|
176 | return 1; |
---|
177 | } |
---|
178 | setchoiceboxselection(device, mdev); |
---|
179 | path = getconfig("mountpath", NULL); |
---|
180 | path = ostrcat(path, "/", 0, 0); |
---|
181 | path = ostrcat(path, mdev, 1, 0); |
---|
182 | |
---|
183 | dirall = get_dir(path); |
---|
184 | free(path); path = NULL; |
---|
185 | |
---|
186 | changetext(text2, dirall); |
---|
187 | free(dirall); dirall = NULL; |
---|
188 | |
---|
189 | free(mdev); mdev=NULL; |
---|
190 | |
---|
191 | drawscreen(multipart, 0, 0); |
---|
192 | addscreenrc(multipart, listbox); |
---|
193 | tmp = listbox->select; |
---|
194 | while(1) |
---|
195 | { |
---|
196 | addscreenrc(multipart, tmp); |
---|
197 | rcret = waitrc(multipart, 2000, 0); |
---|
198 | tmp = listbox->select; |
---|
199 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
200 | |
---|
201 | if((rcret == getrcconfigint("rcleft", NULL) || rcret == getrcconfigint("rcright", NULL)) && listbox->select != NULL && ostrcmp(listbox->select->name, "device") == 0) |
---|
202 | { |
---|
203 | mdev = ostrcat(mdev, device->ret, 1, 0); |
---|
204 | path = getconfig("mountpath", NULL); |
---|
205 | path = ostrcat(path, "/", 0, 0); |
---|
206 | path = ostrcat(path, mdev, 1, 0); |
---|
207 | dirall = get_dir(path); |
---|
208 | free(path); path = NULL; |
---|
209 | changetext(text2, dirall); |
---|
210 | free(dirall); dirall = NULL; |
---|
211 | free(mdev); mdev = NULL; |
---|
212 | } |
---|
213 | |
---|
214 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
215 | { |
---|
216 | mdev = ostrcat(mdev, device->ret, 1, 0); |
---|
217 | cmd = ostrcat("umount /dev/", mdev, 0, 0); |
---|
218 | debug(81, "unmount cmd: %s", cmd); |
---|
219 | ret = system(cmd); |
---|
220 | free(cmd); cmd = NULL; |
---|
221 | break; |
---|
222 | } |
---|
223 | if(rcret == getrcconfigint("rcgreen", NULL)) |
---|
224 | { |
---|
225 | mdev = ostrcat(mdev, device->ret, 1, 0); |
---|
226 | path = getconfig("mountpath", NULL); |
---|
227 | path = ostrcat(path, "/", 0, 0); |
---|
228 | path = ostrcat(path, mdev, 1, 0); |
---|
229 | |
---|
230 | cmd = ostrcat("mount | grep ", mdev, 0, 0); |
---|
231 | cmd = ostrcat(cmd, " | grep ext[2,3,4]", 1, 0); |
---|
232 | ret = system(cmd); |
---|
233 | free(cmd); cmd = NULL; |
---|
234 | if(ret == 0) |
---|
235 | { |
---|
236 | cmd = ostrcat(path, "/", 0, 0); |
---|
237 | cmd = ostrcat(cmd, "titan_multi", 1, 0); |
---|
238 | mkdir(cmd, 777); |
---|
239 | free(cmd); cmd=NULL; |
---|
240 | ren = 1; |
---|
241 | } |
---|
242 | else |
---|
243 | { |
---|
244 | textbox("ERROR", _("No Linux partition found on this device."), _("OK"), getrcconfigint("rcok", NULL),NULL, 0, NULL, 0, NULL, 0, 600, 200, 0, 0); |
---|
245 | ren = 0; |
---|
246 | } |
---|
247 | free(path); path=NULL; |
---|
248 | free(mdev); mdev=NULL; |
---|
249 | if(ren == 1) |
---|
250 | break; |
---|
251 | } |
---|
252 | drawscreen(multipart, 0, 0); |
---|
253 | } |
---|
254 | delownerrc(multipart); |
---|
255 | clearscreen(multipart); |
---|
256 | |
---|
257 | if(mdev == NULL) |
---|
258 | return 1; |
---|
259 | |
---|
260 | if(ren != 1) |
---|
261 | { |
---|
262 | if(textbox("MultiImage", _("All data on this device will be deleted!\nOK?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 650, 200, 0, 0) == 2) |
---|
263 | { |
---|
264 | free(mdev); mdev = NULL; |
---|
265 | return 1; |
---|
266 | } |
---|
267 | cmd = ostrcat("mkfs.ext2.gui /dev/" , mdev, 0, 0); |
---|
268 | debug(81, "format cmd: %s", cmd); |
---|
269 | ret = system(cmd); |
---|
270 | free(cmd); cmd = NULL; |
---|
271 | if(ret != 0) |
---|
272 | { |
---|
273 | textbox(_("Message"), _("ERROR\nPartition could not be created"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 500, 200, 0, 0); |
---|
274 | return 1; |
---|
275 | } |
---|
276 | path = getconfig("mountpath", NULL); |
---|
277 | path = ostrcat(path, "/", 0, 0); |
---|
278 | path = ostrcat(path, mdev, 1, 0); |
---|
279 | cmd = ostrcat("mount /dev/" , mdev, 0, 0); |
---|
280 | cmd = ostrcat(cmd, " ", 1, 0); |
---|
281 | cmd = ostrcat(cmd, path, 1, 0); |
---|
282 | //system(cmd); |
---|
283 | free(cmd); cmd = NULL; |
---|
284 | cmd = ostrcat(path, "/", 0, 0); |
---|
285 | cmd = ostrcat(cmd, "titan_multi", 1, 0); |
---|
286 | mkdir(cmd, 777); |
---|
287 | free(cmd); cmd = NULL; |
---|
288 | free(path); path = NULL; |
---|
289 | free(mdev); mdev = NULL; |
---|
290 | system ("echo MultiImage > /dev/vfd"); |
---|
291 | } |
---|
292 | |
---|
293 | return 0; |
---|
294 | } |
---|
295 | |
---|
296 | // type 1 = install image |
---|
297 | // type 2 = rename image |
---|
298 | int multiimage_install(char* imagefile, char* mdev, int type) |
---|
299 | { |
---|
300 | int rcret = 0; |
---|
301 | int rc = 0; |
---|
302 | char* path = NULL; |
---|
303 | char* path2 = NULL; |
---|
304 | char* path3 = NULL; |
---|
305 | char* cmd = NULL; |
---|
306 | char* temp = NULL; |
---|
307 | char* iname = NULL; |
---|
308 | |
---|
309 | struct skin* tmp = NULL; |
---|
310 | struct skin* multiinstall = getscreen("multiinstall"); |
---|
311 | struct skin* listbox = getscreennode(multiinstall, "listbox"); |
---|
312 | struct skin* text1 = getscreennode(multiinstall, "text1"); |
---|
313 | struct skin* imagename = getscreennode(multiinstall, "imagename"); |
---|
314 | struct skin* b2 = getscreennode(multiinstall, "b2"); |
---|
315 | if(type == 1) |
---|
316 | { |
---|
317 | changetext(b2, _("INSTALL")); |
---|
318 | changeinput(imagename, "imagename"); |
---|
319 | } |
---|
320 | if(type == 2) |
---|
321 | { |
---|
322 | changetext(b2, _("RENAME")); |
---|
323 | changeinput(imagename, imagefile); |
---|
324 | } |
---|
325 | |
---|
326 | path = getconfig("mountpath", NULL); |
---|
327 | path = ostrcat(path, "/", 0, 0); |
---|
328 | path = ostrcat(path, mdev, 1, 0); |
---|
329 | |
---|
330 | path2 = ostrcat(path, "/", 0, 0); |
---|
331 | path2 = ostrcat(path2,"titan_multi", 1, 0); |
---|
332 | |
---|
333 | changetext(text1, imagefile); |
---|
334 | |
---|
335 | |
---|
336 | drawscreen(multiinstall, 0, 0); |
---|
337 | addscreenrc(multiinstall, listbox); |
---|
338 | tmp = listbox->select; |
---|
339 | while(1) |
---|
340 | { |
---|
341 | addscreenrc(multiinstall, tmp); |
---|
342 | rcret = waitrc(multiinstall, 2000, 0); |
---|
343 | tmp = listbox->select; |
---|
344 | if(rcret == getrcconfigint("rcexit", NULL)) |
---|
345 | break; |
---|
346 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
347 | { |
---|
348 | path3 = ostrcat(path2, "/", 0, 0); |
---|
349 | path3 = ostrcat(path3, imagename->ret, 1, 0); |
---|
350 | if(file_exist(path3) == 1) |
---|
351 | { |
---|
352 | free(path3); path3=NULL; |
---|
353 | textbox(_("Message"), _("ERROR\nImage already present!"), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 500, 200, 0, 0); |
---|
354 | continue; |
---|
355 | } |
---|
356 | if(type == 1) |
---|
357 | { |
---|
358 | iname = ostrcat(imagename->ret, NULL, 1, 0); |
---|
359 | rc = 1; |
---|
360 | break; |
---|
361 | } |
---|
362 | if(type == 2) |
---|
363 | { |
---|
364 | temp = ostrcat(path2, "/", 0, 0); |
---|
365 | temp = ostrcat(temp, imagefile, 1, 0); |
---|
366 | cmd = ostrcat("mv ", temp, 0, 0); |
---|
367 | cmd = ostrcat(cmd, " ", 1, 0); |
---|
368 | cmd = ostrcat(cmd, path3, 1, 0); |
---|
369 | system(cmd); |
---|
370 | free(cmd); cmd=NULL; |
---|
371 | free(temp); temp=NULL; |
---|
372 | rc = 2; |
---|
373 | break; |
---|
374 | } |
---|
375 | } |
---|
376 | drawscreen(multiinstall, 0, 0); |
---|
377 | } |
---|
378 | delownerrc(multiinstall); |
---|
379 | clearscreen(multiinstall); |
---|
380 | if(rc == 1) |
---|
381 | { |
---|
382 | if(imagepath != NULL) |
---|
383 | free(imagepath); |
---|
384 | imagepath = NULL; |
---|
385 | imagepath = ostrcat(path2, "/", 0, 0); |
---|
386 | imagepath = ostrcat(imagepath, iname, 1, 0); |
---|
387 | temp = createpluginpath("/multiimage/ubireader/ubi_reader-master/scripts/ubireader_extract_files", 0); |
---|
388 | cmd = createpluginpath("/multiimage/multi_unpack.sh", 0); |
---|
389 | cmd = ostrcat(cmd, " ", 1, 0); |
---|
390 | cmd = ostrcat(cmd, imagefile, 1, 0); |
---|
391 | cmd = ostrcat(cmd, " ", 1, 0); |
---|
392 | cmd = ostrcat(cmd, iname, 1, 0); |
---|
393 | cmd = ostrcat(cmd, " ", 1, 0); |
---|
394 | cmd = ostrcat(cmd, path, 1, 0); |
---|
395 | cmd = ostrcat(cmd, " ", 1, 0); |
---|
396 | cmd = ostrcat(cmd, temp, 1, 0); |
---|
397 | cmd = ostrcat(cmd, " &", 1, 0); |
---|
398 | system(cmd); |
---|
399 | free(cmd); cmd=NULL; |
---|
400 | free(temp); temp=NULL; |
---|
401 | textbox(_("Message"), _("Extracting will take a few minutes ...\n\nProcess is running in background.\nA message will be shown when finished."), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 300, 10, 0); |
---|
402 | Multi_Image_thread = addtimer(&multiimage_thread, START, 10000, 1, NULL, NULL, NULL); |
---|
403 | } |
---|
404 | |
---|
405 | free(path); path=NULL; |
---|
406 | free(path2); path2=NULL; |
---|
407 | free(path3); path3=NULL; |
---|
408 | return rc; |
---|
409 | } |
---|
410 | |
---|
411 | int multiimage_screen(char* mdev) |
---|
412 | { |
---|
413 | struct skin* tmp = NULL; |
---|
414 | char* path = NULL; |
---|
415 | char* cmd = NULL; |
---|
416 | char* tmpstr = NULL; |
---|
417 | char* selimage = NULL; |
---|
418 | struct dirent* dirzeiger; |
---|
419 | DIR *dir = NULL; |
---|
420 | int rcret = 0; |
---|
421 | int rc = 0; |
---|
422 | int test = 0; |
---|
423 | int test2 = 0; |
---|
424 | |
---|
425 | struct skin* multiimage = getscreen("multiimage"); |
---|
426 | struct skin* listbox = getscreennode(multiimage, "listbox"); |
---|
427 | struct skin* images = getscreennode(multiimage, "images"); |
---|
428 | struct skin* chnode1 = NULL; |
---|
429 | |
---|
430 | path = getconfig("mountpath", NULL); |
---|
431 | path = ostrcat(path, "/", 0, 0); |
---|
432 | path = ostrcat(path, mdev, 1, 0); |
---|
433 | path = ostrcat(path, "/", 1, 0); |
---|
434 | path = ostrcat(path,"titan_multi", 1, 0); |
---|
435 | |
---|
436 | delmarkedscreennodes(multiimage, 1); |
---|
437 | listbox->aktpage = -1; |
---|
438 | listbox->aktline = 1; |
---|
439 | |
---|
440 | tmpstr = ostrcat(path, "/", 0, 0); |
---|
441 | tmpstr = ostrcat(tmpstr, ".multi_image", 1, 0); |
---|
442 | selimage = readsys(tmpstr, 1); |
---|
443 | free(tmpstr); tmpstr=NULL; |
---|
444 | |
---|
445 | test2 = 0; |
---|
446 | dir = opendir(path); |
---|
447 | if (dir != 0) |
---|
448 | { |
---|
449 | while(0 != (dirzeiger = readdir(dir))) |
---|
450 | { |
---|
451 | if(dirzeiger->d_name[0] != '.') |
---|
452 | { |
---|
453 | test = 1; |
---|
454 | chnode1 = addlistbox(multiimage, listbox, chnode1, 1); |
---|
455 | if(chnode1 != NULL) |
---|
456 | { |
---|
457 | chnode1->posy = images->posy; |
---|
458 | chnode1->width = images->width; |
---|
459 | chnode1->height = images->height; |
---|
460 | chnode1->bordersize = images->bordersize; |
---|
461 | chnode1->bordercol = images->bordercol; |
---|
462 | chnode1->prozwidth = images->prozwidth; |
---|
463 | chnode1->deaktivcol = images->deaktivcol; |
---|
464 | chnode1->name = ostrcat(dirzeiger->d_name, NULL, 0, 0); |
---|
465 | if(selimage != NULL && ostrcmp(selimage, dirzeiger->d_name) == 0) |
---|
466 | { |
---|
467 | tmpstr = ostrcat(dirzeiger->d_name, " (selected)", 0, 0); |
---|
468 | changetext(chnode1, tmpstr); |
---|
469 | free(tmpstr); tmpstr=NULL; |
---|
470 | test2 = 1; |
---|
471 | } |
---|
472 | else |
---|
473 | changetext(chnode1, dirzeiger->d_name); |
---|
474 | } |
---|
475 | } |
---|
476 | } |
---|
477 | closedir(dir); |
---|
478 | free(selimage); selimage = NULL; |
---|
479 | if(test == 0) |
---|
480 | images->hidden = NO; |
---|
481 | else |
---|
482 | { |
---|
483 | images->hidden = YES; |
---|
484 | chnode1 = addlistbox(multiimage, listbox, chnode1, 1); |
---|
485 | if(chnode1 != NULL) |
---|
486 | { |
---|
487 | chnode1->posy = images->posy; |
---|
488 | chnode1->width = images->width; |
---|
489 | chnode1->height = images->height; |
---|
490 | chnode1->bordersize = images->bordersize; |
---|
491 | chnode1->bordercol = images->bordercol; |
---|
492 | chnode1->prozwidth = images->prozwidth; |
---|
493 | chnode1->deaktivcol = images->deaktivcol; |
---|
494 | chnode1->name = ostrcat("Flash", NULL, 0, 0); |
---|
495 | if(test2 == 0) |
---|
496 | changetext(chnode1, "Flash (selected)"); |
---|
497 | else |
---|
498 | changetext(chnode1, "Flash"); |
---|
499 | } |
---|
500 | } |
---|
501 | } |
---|
502 | drawscreen(multiimage, 0, 0); |
---|
503 | addscreenrc(multiimage, listbox); |
---|
504 | tmp = listbox->select; |
---|
505 | while(1) |
---|
506 | { |
---|
507 | addscreenrc(multiimage, tmp); |
---|
508 | rcret = waitrc(multiimage, 2000, 0); |
---|
509 | tmp = listbox->select; |
---|
510 | if(rcret == getrcconfigint("rcok", NULL)) |
---|
511 | { |
---|
512 | if(listbox->select != NULL) |
---|
513 | { |
---|
514 | rc = 1; |
---|
515 | tmpstr = ostrcat(path, "/", 0, 0); |
---|
516 | tmpstr = ostrcat(tmpstr, ".multi_image", 1, 0); |
---|
517 | writesys(tmpstr, listbox->select->name, 0); |
---|
518 | free(tmpstr); tmpstr=NULL; |
---|
519 | break; |
---|
520 | } |
---|
521 | } |
---|
522 | if(rcret == getrcconfigint("rcexit", NULL)) |
---|
523 | { |
---|
524 | rc = 0; |
---|
525 | break; |
---|
526 | } |
---|
527 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
528 | { |
---|
529 | if(listbox->select != NULL) |
---|
530 | { |
---|
531 | rc = 1; |
---|
532 | cmd = ostrcat(_("Sure to delete Image?\n"), listbox->select->name, 0, 0); |
---|
533 | if(textbox("MultiImage", cmd, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1) |
---|
534 | { |
---|
535 | free(cmd); cmd= NULL; |
---|
536 | cmd = ostrcat("rm -r " , path, 0, 0); |
---|
537 | cmd = ostrcat(cmd , "/", 1, 0); |
---|
538 | cmd = ostrcat(cmd , listbox->select->name, 1, 0); |
---|
539 | debug(81, "delete cmd: %s", cmd); |
---|
540 | system(cmd); |
---|
541 | } |
---|
542 | free(cmd); cmd= NULL; |
---|
543 | break; |
---|
544 | } |
---|
545 | } |
---|
546 | if(rcret == getrcconfigint("rcgreen", NULL)) |
---|
547 | { |
---|
548 | rc = 2; |
---|
549 | break; |
---|
550 | } |
---|
551 | if(rcret == getrcconfigint("rcblue", NULL)) |
---|
552 | { |
---|
553 | rc = 3; |
---|
554 | break; |
---|
555 | } |
---|
556 | if(rcret == getrcconfigint("rcyellow", NULL)) |
---|
557 | { |
---|
558 | rc = 1; |
---|
559 | selimage = ostrcat(listbox->select->name, NULL, 0, 0); |
---|
560 | break; |
---|
561 | } |
---|
562 | if(rcret == getrcconfigint("rcpower", NULL)) |
---|
563 | { |
---|
564 | rc = 4; |
---|
565 | break; |
---|
566 | } |
---|
567 | drawscreen(multiimage, 0, 0); |
---|
568 | } |
---|
569 | delownerrc(multiimage); |
---|
570 | delmarkedscreennodes(multiimage, 1); |
---|
571 | clearscreen(multiimage); |
---|
572 | free(path); path=NULL; |
---|
573 | if(selimage != NULL) |
---|
574 | { |
---|
575 | multiimage_install(selimage, mdev, 2); |
---|
576 | free(selimage); selimage = NULL; |
---|
577 | } |
---|
578 | return rc; |
---|
579 | } |
---|
580 | |
---|
581 | void multi_main(void) |
---|
582 | { |
---|
583 | char* mdev = NULL; |
---|
584 | char* imagefile = NULL; |
---|
585 | int ret = 0; |
---|
586 | |
---|
587 | mdev = find_multiimage_dev(); |
---|
588 | |
---|
589 | while (mdev == NULL) |
---|
590 | { |
---|
591 | if(textbox("MultiImage", _("No MultiImage device found.\nCreate device?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 500, 200, 0, 0) == 2) |
---|
592 | return; |
---|
593 | if(no_mdev() != 0) |
---|
594 | return; |
---|
595 | mdev = find_multiimage_dev(); |
---|
596 | } |
---|
597 | while(1) |
---|
598 | { |
---|
599 | ret = multiimage_screen(mdev); |
---|
600 | |
---|
601 | if(ret == 0) |
---|
602 | break; |
---|
603 | if(ret == 1) |
---|
604 | continue; |
---|
605 | if(ret == 2) |
---|
606 | { |
---|
607 | textbox("Message", _("The install process will look in /tmp for an image zip file.\nPlease copy the image to /tmp. The filename must not contain blanks."), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 800, 200, 0, 0); |
---|
608 | imagefile = screendir("/tmp", "*.zip", NULL, NULL, NULL, NULL, 0, "SELECT", 0, NULL, 0, NULL, 0, 1200, 0, 600, 0, 0); |
---|
609 | if(imagefile != NULL) |
---|
610 | { |
---|
611 | ret = multiimage_install(imagefile, mdev, 1); |
---|
612 | free(imagefile); imagefile=NULL; |
---|
613 | if(ret == 1) |
---|
614 | { |
---|
615 | free(mdev); mdev=NULL; |
---|
616 | return; |
---|
617 | } |
---|
618 | } |
---|
619 | } |
---|
620 | if(ret == 3) |
---|
621 | { |
---|
622 | if(no_mdev() != 0) |
---|
623 | continue; |
---|
624 | free(mdev); mdev=NULL; |
---|
625 | mdev = find_multiimage_dev(); |
---|
626 | } |
---|
627 | if(ret == 4) |
---|
628 | { |
---|
629 | oshutdown(2, 1); |
---|
630 | break; |
---|
631 | } |
---|
632 | } |
---|
633 | free(mdev); mdev=NULL; |
---|
634 | } |
---|
635 | |
---|
636 | |
---|
637 | |
---|
638 | //wird beim laden ausgefuehrt |
---|
639 | void init(void) |
---|
640 | { |
---|
641 | char* tmpstr = NULL; |
---|
642 | pluginaktiv = 1; |
---|
643 | |
---|
644 | tmpstr = createpluginpath("/multiimage/skin.xml", 0); |
---|
645 | readscreen(tmpstr, 122, 1); |
---|
646 | |
---|
647 | debug(10, "MultiImage Plugin loaded!!!"); |
---|
648 | } |
---|
649 | |
---|
650 | //wird beim entladen ausgefuehrt |
---|
651 | void deinit(void) |
---|
652 | { |
---|
653 | if(Multi_Image_thread != NULL) |
---|
654 | { |
---|
655 | Multi_Image_thread->aktion = STOP; |
---|
656 | while (Multi_Image_thread != NULL) |
---|
657 | { |
---|
658 | sleep(1); |
---|
659 | } |
---|
660 | } |
---|
661 | pluginaktiv = 0; |
---|
662 | debug(10, "MultiImage removed !!!"); |
---|
663 | delmarkedscreen(122); |
---|
664 | } |
---|
665 | |
---|
666 | //wird in der Pluginverwaltung bzw Menue ausfeguehrt |
---|
667 | void start(void) |
---|
668 | { |
---|
669 | if(Multi_Image_thread != NULL) |
---|
670 | { |
---|
671 | if(textbox("MultiImage", _("Image creation running!!!\nStop process?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 500, 200, 0, 0) == 2) |
---|
672 | return; |
---|
673 | Multi_Image_thread->aktion = STOP; |
---|
674 | struct skin* load = getscreen("loading"); |
---|
675 | drawscreen(load, 0, 0); |
---|
676 | while (Multi_Image_thread != NULL) |
---|
677 | { |
---|
678 | sleep(1); |
---|
679 | } |
---|
680 | clearscreen(load); |
---|
681 | } |
---|
682 | |
---|
683 | multi_main(); |
---|
684 | } |
---|