Changeset 34476
- Timestamp:
- 06/03/15 18:25:07 (8 years ago)
- Location:
- titan
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
titan/plugins/multiimage/MultiImage.c
r34463 r34476 14 14 15 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 } 16 37 17 38 void multiimage_thread() … … 101 122 102 123 103 char* get_dir(char* path)104 {105 struct dirent* dirzeiger;106 char* dirall = NULL;107 DIR *dir = opendir(path);108 if (dir != 0)109 {110 struct dirent* dirzeiger;111 while(0 != (dirzeiger = readdir(dir)))112 {113 if(dirzeiger->d_name[0] != '.')114 {115 dirall = ostrcat(dirall, dirzeiger->d_name, 1, 0);116 dirall = ostrcat(dirall, " \n", 1, 0);117 }118 }119 closedir(dir);120 }121 return dirall;122 }123 124 125 124 int no_mdev() 126 125 { … … 132 131 int ret = 0; 133 132 int rcret = 0; 133 int ren = 0; 134 134 135 135 struct skin* multipart = getscreen("multipart"); … … 171 171 if(mdev == NULL) 172 172 { 173 textbox("MultiImage", _("No device available"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 500, 200, 0, 0);173 textbox("MultiImage", _("No device available"), _("OK"), getrcconfigint("rcok", NULL),NULL, 0, NULL, 0, NULL, 0, 500, 200, 0, 0); 174 174 return 1; 175 175 } … … 210 210 } 211 211 212 if(rcret == getrcconfigint("rc blue", NULL))212 if(rcret == getrcconfigint("rcred", NULL)) 213 213 { 214 214 mdev = ostrcat(mdev, device->ret, 1, 0); … … 219 219 break; 220 220 } 221 if(rcret == getrcconfigint("rcgreen", NULL)) 222 { 223 mdev = ostrcat(mdev, device->ret, 1, 0); 224 path = getconfig("mountpath", NULL); 225 path = ostrcat(path, "/", 0, 0); 226 path = ostrcat(path, mdev, 1, 0); 227 228 cmd = ostrcat("mount | grep ", mdev, 0, 0); 229 cmd = ostrcat(cmd, " | grep ext[2,3,4]", 1, 0); 230 ret = system(cmd); 231 free(cmd); cmd = NULL; 232 if(ret == 0) 233 { 234 cmd = ostrcat(path, "/", 0, 0); 235 cmd = ostrcat(cmd, "titan_multi", 1, 0); 236 mkdir(cmd, 777); 237 free(cmd); cmd=NULL; 238 ren = 1; 239 } 240 else 241 { 242 textbox("ERROR", _("No Linux partiton found on this device."), _("OK"), getrcconfigint("rcok", NULL),NULL, 0, NULL, 0, NULL, 0, 600, 200, 0, 0); 243 ren = 0; 244 } 245 free(path); path=NULL; 246 free(mdev); mdev=NULL; 247 if(ren == 1) 248 break; 249 } 221 250 drawscreen(multipart, 0, 0); 222 251 } … … 227 256 return 1; 228 257 229 if(textbox("MultiImage", _("All data on this device will be deleted!\nOK?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 2) 230 { 258 if(ren != 1) 259 { 260 if(textbox("MultiImage", _("All data on this device will be deleted!\nOK?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 2) 261 { 262 free(mdev); mdev = NULL; 263 return 1; 264 } 265 cmd = ostrcat("mkfs.ext2.gui /dev/" , mdev, 0, 0); 266 debug(81, "format cmd: %s", cmd); 267 ret = system(cmd); 268 free(cmd); cmd = NULL; 269 if(ret != 0) 270 { 271 textbox(_("Message"), _("ERROR\nPartition could not be created"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 500, 200, 0, 0); 272 return 1; 273 } 274 path = getconfig("mountpath", NULL); 275 path = ostrcat(path, "/", 0, 0); 276 path = ostrcat(path, mdev, 1, 0); 277 cmd = ostrcat("mount /dev/" , mdev, 0, 0); 278 cmd = ostrcat(cmd, " ", 1, 0); 279 cmd = ostrcat(cmd, path, 1, 0); 280 //system(cmd); 281 free(cmd); cmd = NULL; 282 cmd = ostrcat(path, "/", 0, 0); 283 cmd = ostrcat(cmd, "titan_multi", 1, 0); 284 mkdir(cmd, 777); 285 free(cmd); cmd = NULL; 286 free(path); path = NULL; 231 287 free(mdev); mdev = NULL; 232 return 1; 233 } 234 //cmd = ostrcat("/sbin/cmd.sh mkfs.ext2.gui /dev/" , mdev, 0, 0); 235 cmd = ostrcat("mkfs.ext2.gui /dev/" , mdev, 0, 0); 236 debug(81, "format cmd: %s", cmd); 237 ret = system(cmd); 238 free(cmd); cmd = NULL; 239 if(ret != 0) 240 { 241 textbox(_("Message"), _("ERROR\nPartition could not be created"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 500, 200, 0, 0); 242 return 1; 243 } 244 path = getconfig("mountpath", NULL); 245 path = ostrcat(path, "/", 0, 0); 246 path = ostrcat(path, mdev, 1, 0); 247 cmd = ostrcat("mount /dev/" , mdev, 0, 0); 248 cmd = ostrcat(cmd, " ", 1, 0); 249 cmd = ostrcat(cmd, path, 1, 0); 250 //system(cmd); 251 free(cmd); cmd = NULL; 252 cmd = ostrcat(path, "/", 0, 0); 253 cmd = ostrcat(cmd, "titan_multi", 0, 0); 254 mkdir(cmd, 777); 255 free(cmd); cmd = NULL; 256 free(path); path = NULL; 257 free(mdev); mdev = NULL; 258 system ("echo MultiImage > /dev/vfd"); 288 system ("echo MultiImage > /dev/vfd"); 289 } 259 290 260 291 return 0; 261 292 } 262 293 263 int multiimage_screen(char* mdev) 264 { 265 struct skin* tmp = NULL; 266 char* path = NULL; 267 char* cmd = NULL; 268 struct dirent* dirzeiger; 269 DIR *dir = NULL; 270 int rcret = 0; 271 int rc = 0; 272 int test = 0; 273 274 struct skin* multiimage = getscreen("multiimage"); 275 struct skin* listbox = getscreennode(multiimage, "listbox"); 276 struct skin* images = getscreennode(multiimage, "images"); 277 struct skin* chnode1 = NULL; 278 279 path = getconfig("mountpath", NULL); 280 path = ostrcat(path, "/", 0, 0); 281 path = ostrcat(path, mdev, 1, 0); 282 path = ostrcat(path, "/", 1, 0); 283 path = ostrcat(path,"titan_multi", 1, 0); 284 285 delmarkedscreennodes(multiimage, 1); 286 listbox->aktpage = -1; 287 listbox->aktline = 1; 288 289 dir = opendir(path); 290 if (dir != 0) 291 { 292 while(0 != (dirzeiger = readdir(dir))) 293 { 294 if(dirzeiger->d_name[0] != '.') 295 { 296 test = 1; 297 chnode1 = addlistbox(multiimage, listbox, chnode1, 1); 298 if(chnode1 != NULL) 299 { 300 chnode1->posy = images->posy; 301 chnode1->width = images->width; 302 chnode1->height = images->height; 303 chnode1->bordersize = images->bordersize; 304 chnode1->bordercol = images->bordercol; 305 chnode1->prozwidth = images->prozwidth; 306 chnode1->deaktivcol = images->deaktivcol; 307 chnode1->name = ostrcat(dirzeiger->d_name, NULL, 0, 0); 308 changetext(chnode1, dirzeiger->d_name); 309 } 310 } 311 } 312 closedir(dir); 313 if(test == 0) 314 images->hidden = NO; 315 else 316 images->hidden = YES; 317 } 318 drawscreen(multiimage, 0, 0); 319 addscreenrc(multiimage, listbox); 320 tmp = listbox->select; 321 while(1) 322 { 323 addscreenrc(multiimage, tmp); 324 rcret = waitrc(multiimage, 2000, 0); 325 tmp = listbox->select; 326 if(rcret == getrcconfigint("rcexit", NULL)) 327 { 328 rc = 0; 329 break; 330 } 331 if(rcret == getrcconfigint("rcred", NULL)) 332 { 333 if(listbox->select != NULL) 334 { 335 rc = 1; 336 cmd = ostrcat(_("Sure to delete Image?\n"), listbox->select->name, 0, 0); 337 if(textbox("MultiImage", cmd, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1) 338 { 339 free(cmd); cmd= NULL; 340 cmd = ostrcat("rm -r " , path, 0, 0); 341 cmd = ostrcat(cmd , "/", 1, 0); 342 cmd = ostrcat(cmd , listbox->select->name, 1, 0); 343 debug(81, "delete cmd: %s", cmd); 344 system(cmd); 345 } 346 free(cmd); cmd= NULL; 347 break; 348 } 349 } 350 if(rcret == getrcconfigint("rcgreen", NULL)) 351 { 352 rc = 2; 353 break; 354 } 355 if(rcret == getrcconfigint("rcblue", NULL)) 356 { 357 rc = 3; 358 break; 359 } 360 drawscreen(multiimage, 0, 0); 361 } 362 delownerrc(multiimage); 363 delmarkedscreennodes(multiimage, 1); 364 clearscreen(multiimage); 365 free(path); path=NULL; 366 367 return rc; 368 } 369 370 int multiimage_install(char* imagefile, char* mdev) 294 // type 1 = install image 295 // type 2 = rename image 296 int multiimage_install(char* imagefile, char* mdev, int type) 371 297 { 372 298 int rcret = 0; … … 384 310 struct skin* text1 = getscreennode(multiinstall, "text1"); 385 311 struct skin* imagename = getscreennode(multiinstall, "imagename"); 312 struct skin* b2 = getscreennode(multiinstall, "b2"); 313 if(type == 1) 314 { 315 changetext(b2, _("INSTALL")); 316 changeinput(imagename, "imagename"); 317 } 318 if(type == 2) 319 { 320 changetext(b2, _("RENAME")); 321 changeinput(imagename, imagefile); 322 } 386 323 387 324 path = getconfig("mountpath", NULL); … … 393 330 394 331 changetext(text1, imagefile); 395 changeinput(imagename, "imagename");332 396 333 397 334 drawscreen(multiinstall, 0, 0); … … 415 352 continue; 416 353 } 417 textbox(_("Message"), _("INFO\nExtracting will take a few minutes ..."), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 200, 0, 0); 418 iname = ostrcat(imagename->ret, NULL, 1, 0); 419 rc = 1; 420 break; 354 if(type == 1) 355 { 356 textbox(_("Message"), _("INFO\nExtracting will take a few minutes ..."), _("OK"), getrcconfigint("rcok", NULL), NULL, 0, NULL, 0, NULL, 0, 600, 200, 0, 0); 357 iname = ostrcat(imagename->ret, NULL, 1, 0); 358 rc = 1; 359 break; 360 } 361 if(type == 2) 362 { 363 temp = ostrcat(path2, "/", 0, 0); 364 temp = ostrcat(temp, imagefile, 1, 0); 365 cmd = ostrcat("mv ", temp, 0, 0); 366 cmd = ostrcat(cmd, " ", 1, 0); 367 cmd = ostrcat(cmd, path3, 1, 0); 368 system(cmd); 369 free(cmd); cmd=NULL; 370 free(temp); temp=NULL; 371 rc = 2; 372 break; 373 } 421 374 } 422 375 drawscreen(multiinstall, 0, 0); … … 456 409 } 457 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 424 struct skin* multiimage = getscreen("multiimage"); 425 struct skin* listbox = getscreennode(multiimage, "listbox"); 426 struct skin* images = getscreennode(multiimage, "images"); 427 struct skin* chnode1 = NULL; 428 429 path = getconfig("mountpath", NULL); 430 path = ostrcat(path, "/", 0, 0); 431 path = ostrcat(path, mdev, 1, 0); 432 path = ostrcat(path, "/", 1, 0); 433 path = ostrcat(path,"titan_multi", 1, 0); 434 435 delmarkedscreennodes(multiimage, 1); 436 listbox->aktpage = -1; 437 listbox->aktline = 1; 438 439 tmpstr = ostrcat(path, "/", 0, 0); 440 tmpstr = ostrcat(tmpstr, ".multi_image", 1, 0); 441 selimage = readsys(tmpstr, 1); 442 free(tmpstr); tmpstr=NULL; 443 444 dir = opendir(path); 445 if (dir != 0) 446 { 447 while(0 != (dirzeiger = readdir(dir))) 448 { 449 if(dirzeiger->d_name[0] != '.') 450 { 451 test = 1; 452 chnode1 = addlistbox(multiimage, listbox, chnode1, 1); 453 if(chnode1 != NULL) 454 { 455 chnode1->posy = images->posy; 456 chnode1->width = images->width; 457 chnode1->height = images->height; 458 chnode1->bordersize = images->bordersize; 459 chnode1->bordercol = images->bordercol; 460 chnode1->prozwidth = images->prozwidth; 461 chnode1->deaktivcol = images->deaktivcol; 462 chnode1->name = ostrcat(dirzeiger->d_name, NULL, 0, 0); 463 if(selimage != NULL && ostrcmp(selimage, dirzeiger->d_name) == 0) 464 { 465 tmpstr = ostrcat(dirzeiger->d_name, " (selected)", 0, 0); 466 changetext(chnode1, tmpstr); 467 free(tmpstr); tmpstr=NULL; 468 test = 2; 469 } 470 else 471 changetext(chnode1, dirzeiger->d_name); 472 } 473 } 474 } 475 closedir(dir); 476 free(selimage); selimage = NULL; 477 if(test == 0) 478 images->hidden = NO; 479 else 480 { 481 images->hidden = YES; 482 chnode1 = addlistbox(multiimage, listbox, chnode1, 1); 483 if(chnode1 != NULL) 484 { 485 chnode1->posy = images->posy; 486 chnode1->width = images->width; 487 chnode1->height = images->height; 488 chnode1->bordersize = images->bordersize; 489 chnode1->bordercol = images->bordercol; 490 chnode1->prozwidth = images->prozwidth; 491 chnode1->deaktivcol = images->deaktivcol; 492 chnode1->name = ostrcat("Flash", NULL, 0, 0); 493 if(test == 1) 494 changetext(chnode1, "Flash (selected)"); 495 else 496 changetext(chnode1, "Flash"); 497 } 498 } 499 } 500 drawscreen(multiimage, 0, 0); 501 addscreenrc(multiimage, listbox); 502 tmp = listbox->select; 503 while(1) 504 { 505 addscreenrc(multiimage, tmp); 506 rcret = waitrc(multiimage, 2000, 0); 507 tmp = listbox->select; 508 if(rcret == getrcconfigint("rcok", NULL)) 509 { 510 if(listbox->select != NULL) 511 { 512 rc = 1; 513 tmpstr = ostrcat(path, "/", 0, 0); 514 tmpstr = ostrcat(tmpstr, ".multi_image", 1, 0); 515 writesys(tmpstr, listbox->select->name, 0); 516 free(tmpstr); tmpstr=NULL; 517 break; 518 } 519 } 520 if(rcret == getrcconfigint("rcexit", NULL)) 521 { 522 rc = 0; 523 break; 524 } 525 if(rcret == getrcconfigint("rcred", NULL)) 526 { 527 if(listbox->select != NULL) 528 { 529 rc = 1; 530 cmd = ostrcat(_("Sure to delete Image?\n"), listbox->select->name, 0, 0); 531 if(textbox("MultiImage", cmd, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1) 532 { 533 free(cmd); cmd= NULL; 534 cmd = ostrcat("rm -r " , path, 0, 0); 535 cmd = ostrcat(cmd , "/", 1, 0); 536 cmd = ostrcat(cmd , listbox->select->name, 1, 0); 537 debug(81, "delete cmd: %s", cmd); 538 system(cmd); 539 } 540 free(cmd); cmd= NULL; 541 break; 542 } 543 } 544 if(rcret == getrcconfigint("rcgreen", NULL)) 545 { 546 rc = 2; 547 break; 548 } 549 if(rcret == getrcconfigint("rcblue", NULL)) 550 { 551 rc = 3; 552 break; 553 } 554 if(rcret == getrcconfigint("rcyellow", NULL)) 555 { 556 rc = 1; 557 selimage = ostrcat(listbox->select->name, NULL, 0, 0); 558 break; 559 } 560 drawscreen(multiimage, 0, 0); 561 } 562 delownerrc(multiimage); 563 delmarkedscreennodes(multiimage, 1); 564 clearscreen(multiimage); 565 free(path); path=NULL; 566 if(selimage != NULL) 567 { 568 multiimage_install(selimage, mdev, 2); 569 free(selimage); selimage = NULL; 570 } 571 return rc; 572 } 573 458 574 void multi_main(void) 459 575 { … … 478 594 if(ret == 0) 479 595 break; 596 if(ret == 1) 597 continue; 480 598 if(ret == 2) 481 599 { … … 484 602 if(imagefile != NULL) 485 603 { 486 ret = multiimage_install(imagefile, mdev );604 ret = multiimage_install(imagefile, mdev, 1); 487 605 free(imagefile); imagefile=NULL; 488 606 if(ret == 1) -
titan/skins/multiimage/skin.xml
r34452 r34476 5 5 <node name="textbox2" type="textbox" text="DIR" scrollbar="auto" posy=135 posx=center width=85% height=300 fontsize=20> 6 6 <node name=b2 text="EXIT" halign=center valign=middle bordercol=exitcol bordersize=2 bordertype=2 posx=0 posy=0 width=150 height=30/> 7 <node name=blue text="format" halign=center valign=middle bordercol=blue bordersize=2 bordertype=2 posx=160 posy=0 width=150 height=30/> 7 <node name=red text="Format" halign=center valign=middle bordercol=red bordersize=2 bordertype=2 posx=160 posy=0 width=150 height=30/> 8 <node name=green text="Create" halign=center valign=middle bordercol=green bordersize=2 bordertype=2 posx=320 posy=0 width=150 height=30/> 8 9 </screen> 9 10 10 <screen name="multiimage" title="Manage MultiImage" titlealign=center fontcol=fontcol valign=bottom fontsize=28 posx=center posy=center width=50% height=70% bordercol=bordercol bordersize=2 bgcol=bgcol> 11 <node bordercol=bordercol scrollbar=auto type=listbox posy=center posx=center name=listbox width=85% height=85%> 11 <screen name="multiimage" title="Manage MultiImage" titlealign=center fontcol=fontcol valign=bottom fontsize=28 posx=center posy=center width=65% height=70% bordercol=bordercol bordersize=2 bgcol=bgcol> 12 <node name="hint" type="textbox" fontsize="22" posx=center posy="20" width=85% height=30 fontcol=yellow text="OK = select image"> 13 <node bordercol=bordercol scrollbar=auto type=listbox posy=80 posx=center name=listbox width=85% height=85%> 12 14 <node name="images" text="No image installed" parent=listbox valign=middle posx=0 bordercol=bordercol bordersize=2 width=100% height=30 hidden="yes"> 13 15 <node name=b1 text="EXIT" halign=center valign=middle bordercol=exitcol bordersize=2 bordertype=2 posx=0 posy=0 width=150 height=30/> 14 16 <node name=b2 text="Delete" halign=center valign=middle bordercol=red bordersize=2 bordertype=2 posx=160 posy=0 width=150 height=30/> 15 17 <node name=b3 text="Install" halign=center valign=middle bordercol=green bordersize=2 bordertype=2 posx=320 posy=0 width=150 height=30/> 16 <node name=b3 text="Format" halign=center valign=middle bordercol=blue bordersize=2 bordertype=2 posx=480 posy=0 width=150 height=30/> 18 <node name=b4 text="Format" halign=center valign=middle bordercol=blue bordersize=2 bordertype=2 posx=480 posy=0 width=150 height=30/> 19 <node name=b5 text="Rename" halign=center valign=middle bordercol=yellow bordersize=2 bordertype=2 posx=640 posy=0 width=150 height=30/> 17 20 </screen> 18 21 19 <screen name="multiinstall" title="MultiImage Install ation" titlealign=center fontcol=fontcol valign=bottom fontsize=28 posx=center posy=center width=65% height=55% bordercol=bordercol bordersize=2 bgcol=bgcol>22 <screen name="multiinstall" title="MultiImage Install/Rename" titlealign=center fontcol=fontcol valign=bottom fontsize=28 posx=center posy=center width=65% height=55% bordercol=bordercol bordersize=2 bgcol=bgcol> 20 23 <node name="hint" type="textbox" fontsize="22" posx=center posy="40" width=85% height=30 text="Hint: Use TEXT button for editing the image name"> 21 24 <node name="text1" type="textbox" fontsize="20" posx=center posy="100" width=85% height=30 text="Selected image">
Note: See TracChangeset
for help on using the changeset viewer.