Changeset 13004 for titan/titan/ipkg.h
- Timestamp:
- 01/09/12 12:31:07 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
titan/titan/ipkg.h
r12873 r13004 227 227 int ipkg_install(const char* package) 228 228 { 229 printf("package: %s\n",package); 230 229 231 int err = 0; 230 232 args_t args; 231 232 args_init(&args); 233 args_init(&args); 234 235 printf("4444444\n"); 233 236 err = ipkg_packages_install(&args, package); 234 args_deinit(&args); 235 237 printf("5555555\n"); 238 args_deinit(&args); 239 printf("6666666\n"); 236 240 return err; 237 241 } … … 270 274 ip = string_replace("http://", "", src, 0); 271 275 272 273 274 276 if(ip != NULL) 277 pos = strchr(ip, '/'); 278 if(pos != NULL) 275 279 { 276 280 pos[0] = '\0'; … … 278 282 } 279 283 280 err = screendownload("Download", ip, path, 80, (char*)filename, "YXRlbWlvOkZIWlZCR2huemZ2RWhGREZUR3p1aWY1Njc2emhqR1RVR0JOSGpt", 0); 284 struct splitstr* ret1 = NULL; 285 int count1 = 0; 286 char* tmpstr1 = NULL; 287 tmpstr1 = ostrcat("", path, 0, 0); 288 ret1 = strsplit(tmpstr1, "/", &count1); 289 int max = count1; 290 int i = 0; 291 int withoutgui = 0; 292 for( i = 0; i < max; i++){ 293 if(ostrcmp("Packages.gz", (&ret1[i])->part) == 0) 294 withoutgui = 1; 295 } 296 free(ret1),ret1 = NULL; 297 if(withoutgui == 1) 298 { 299 char* checkfile = NULL; 300 checkfile = ostrcat("/tmp/Packages.", ip, 0, 0); 301 302 if(!file_exist(checkfile)) // +status.ipkg = date + 1day 303 { 304 char* tmppath = NULL; 305 tmppath = ostrcat(tmppath, path, 1, 0); 306 tmppath = string_replace("Packages.gz", "Packages.preview.tar.gz", tmppath, 0); 307 gethttp(ip, tmppath, 80, "/tmp/Packages.preview.tar.gz", "YXRlbWlvOkZIWlZCR2huemZ2RWhGREZUR3p1aWY1Njc2emhqR1RVR0JOSGpt", NULL); 308 free(tmppath),tmppath = NULL; 309 system("tar -zxvf /tmp/Packages.preview.tar.gz -C /tmp"); 310 unlink("/tmp/Packages.preview.tar.gz"); 311 char* cmd = NULL; 312 cmd = ostrcat("touch ", checkfile, 0, 0); 313 system(cmd); 314 free(cmd),cmd = NULL; 315 } 316 free(checkfile),checkfile = NULL; 317 err = gethttp(ip, path, 80, (char*)filename, "YXRlbWlvOkZIWlZCR2huemZ2RWhGREZUR3p1aWY1Njc2emhqR1RVR0JOSGpt", NULL); 318 } 319 else 320 err = screendownload("Download", ip, path, 80, (char*)filename, "YXRlbWlvOkZIWlZCR2huemZ2RWhGREZUR3p1aWY1Njc2emhqR1RVR0JOSGpt", 0); 321 281 322 free(ip); ip = NULL; 282 323 printf("out"); 283 324 return err; 284 325 } … … 335 376 } 336 377 378 /* not needed anymore 337 379 char* get_ipk_list(char* section) 338 380 { … … 349 391 { 350 392 namelist = ostrcat(namelist, node->name, 1, 0); 351 namelist = ostrcat(namelist, " - ", 1, 0);352 namelist = ostrcat(namelist, node->version, 1, 0);353 namelist = ostrcat(namelist, " - ", 1, 0);354 if(node->desc != NULL)355 namelist = ostrcat(namelist, node->desc, 1, 0);356 else357 namelist = ostrcat(namelist, "no description", 1, 0);358 393 namelist = ostrcat(namelist, "\n", 1, 0); 359 394 } … … 364 399 return namelist; 365 400 } 401 */ 402 403 char* ipk_listbox(char* defaultstr, char* str, char* skinname, char* skintitle, char* skinpath, int showpng) 404 { 405 debug(1000, "in"); 406 char* skinname1 = NULL; 407 char* skinpath1 = NULL; 408 char* tmpskinpath = NULL; 409 int rcret = 0; 410 411 if(str == NULL) 412 return 0; 413 414 if(skinname == NULL) 415 { 416 debug(60, "skinname default=menulist"); 417 skinname1 = ostrcat(skinname, "menulist", 1, 0); 418 } 419 else 420 { 421 debug(60, "skinname changed=%s", skinname); 422 skinname1 = ostrcat(skinname, "", 0, 0); 423 } 424 425 if(skinpath == NULL) 426 { 427 debug(60, "skinpath default=skin/"); 428 skinpath1 = ostrcat(skinpath, "skin/", 1, 0); 429 } 430 else 431 { 432 debug(60, "skinpath changed=%s", skinpath); 433 skinpath1 = ostrcat(skinpath, "", 0, 0); 434 } 435 436 struct skin* screen = getscreen(skinname1); 437 struct skin* listbox = getscreennode(screen, "listbox"); 438 439 listbox->aktpage = -1; 440 listbox->aktline = 1; 441 442 if(skintitle != NULL) 443 { 444 debug(60, "skintitle changed=%s", skintitle); 445 changetitle(screen, _(skintitle)); 446 } 447 448 struct skin* tmp = NULL; 449 char* tmpstr = NULL; 450 char* defaultdir = NULL; 451 char* tmpinfo = NULL; 452 char* tmptitle = NULL; 453 char* showname = NULL; 454 // char* tmpstr1 = NULL; 455 // char* tmpck = NULL; 456 char* tmpsplit = NULL; 457 char* tmpck = NULL; 458 char* tmpstr1 = NULL; 459 char* tmpstr4 = NULL; 460 char* tmpstr5 = NULL; 461 if(showpng == 1) 462 { 463 struct splitstr* ret1 = NULL; 464 struct splitstr* ret2 = NULL; 465 struct splitstr* ret3 = NULL; 466 int count = 0; 467 int i = 0; 468 ret1 = strsplit(str, "\n", &count); 469 470 for( i = 0; i < count; i++) 471 { 472 int count2 = 0; 473 tmpsplit = ostrcat(tmpsplit, (&ret1[i])->part, 1, 0); 474 free(ret2); ret2 = NULL; 475 ret2 = strsplit(tmpsplit, "-", &count2); 476 477 tmp = addlistbox(screen, listbox, tmp, 1); 478 479 if(tmp != NULL) 480 { 481 changetext(tmp, _((&ret1[i])->part)); 482 changename(tmp, (&ret1[i])->part); 483 484 tmp->del = 1; 485 tmp->textposx = 120; 486 tmp->height = 50; 487 // tmp->fontsize = 30; 488 tmp->valign = convertxmlentry("middle", 0); 489 tmp->hspace = 5; 490 debug(60, "showpng changed=%d", showpng); 491 492 if(showpng == 1) 493 { 494 if(string_find("%pluginpath%",skinpath1)) 495 { 496 struct splitstr* ret6 = NULL; 497 int count6 = 0; 498 char* tmpstr6 = NULL; 499 tmpstr6 = ostrcat("", skinpath1, 0, 0); 500 ret6 = strsplit(tmpstr6, "%", &count6); 501 defaultdir = ostrcat(getconfig("skinpath", NULL), "/skin/panel_", 0, 0); 502 defaultdir = ostrcat(defaultdir, (&ret1[i])->part, 1, 0); 503 defaultdir = ostrcat(defaultdir, ".png", 1, 0); 504 505 if(!file_exist(defaultdir)) 506 { 507 defaultdir = ostrcat(getconfig("pluginpath", NULL), (&ret6[1])->part, 0, 0); 508 defaultdir = ostrcat(defaultdir, "panel_", 0, 0); 509 defaultdir = ostrcat(defaultdir, (&ret1[i])->part, 1, 0); 510 defaultdir = ostrcat(defaultdir, ".png", 1, 0); 511 } 512 free(ret6), ret6 = NULL; 513 } 514 else 515 { 516 defaultdir = ostrcat(getconfig("skinpath", NULL), skinpath1, 0, 0); 517 defaultdir = ostrcat(defaultdir, "/skin/panel_", 0, 0); 518 defaultdir = ostrcat(defaultdir, (&ret1[i])->part, 1, 0); 519 defaultdir = ostrcat(defaultdir, ".png", 1, 0); 520 } 521 522 debug(60, "defaultdir %s", defaultdir); 523 if(file_exist(defaultdir)) 524 { 525 tmpskinpath = ostrcat("", defaultdir, 0, 0); 526 changepic(tmp, tmpskinpath); 527 free(tmpskinpath); tmpskinpath = NULL; 528 } 529 else 530 { 531 tmpskinpath = ostrcat(skinpath1, "panel_default.png", 0, 0); 532 changepic(tmp, tmpskinpath); 533 free(tmpskinpath); tmpskinpath = NULL; 534 } 535 free(defaultdir); defaultdir = NULL; 536 } 537 538 if(defaultstr != NULL) 539 { 540 setlistboxselection(listbox, defaultstr); 541 // if(ostrcmp(defaultstr, (&ret1[i])->part) == 0) 542 // listbox->aktline = i + 1; 543 } 544 } 545 } 546 } 547 else if(showpng == 2) 548 { 549 tmpck = get_ipk_listinstall(); 550 struct ipkg *node = ipkg; 551 while(node != NULL) 552 { 553 printf("name: %s\n", node->name); 554 printf("section: %s\n", node->section); 555 printf("showname: %s\n", node->showname); 556 printf("str: %s\n", str); 557 558 if(node->section != NULL && ostrcmp(str, node->section) == 0) 559 { 560 struct splitstr* ret1 = NULL; 561 int count1 = 0; 562 tmpstr1 = ostrcat("", node->showname, 0, 0); 563 ret1 = strsplit(tmpstr1, ".", &count1); 564 int max = count1; 565 int i = 0; 566 showname = ostrcat("", (&ret1[0])->part, 0, 0); 567 free(ret1),ret1 = NULL; 568 569 struct splitstr* ret3 = NULL; 570 int count3 = 0; 571 int a = 0; 572 tmpstr1 = ostrcat("", tmpck, 0, 0); 573 574 debug(60, "tmpck: (%d) %s", i, tmpstr1); 575 576 ret3 = strsplit(tmpstr1, "\n", &count3); 577 int skip = 0; 578 for(a = 0; a < count3; a++) 579 { 580 if(ostrcmp((&ret3[a])->part, node->name) == 0) 581 { 582 debug(60, "set skiped=1"); 583 skip = 1; 584 continue; 585 } 586 } 587 if(skip == 0) 588 { 589 tmp = addlistbox(screen, listbox, tmp, 1); 590 tmp->del = 1; 591 tmp->valign = convertxmlentry("middle", 0); 592 printf("321111\n"); 593 tmp->textposx = 250; 594 tmp->height = 170; 595 tmp->textposx2 = 270; 596 tmp->type=TEXTBOX; 597 tmp->wrap=YES; 598 tmp->hspace = 5; 599 debug(60, "showpng changed=%d", showpng); 600 601 defaultdir = ostrcat("", skinpath1, 0, 0); 602 defaultdir = ostrcat(defaultdir, "titan-pluginpreview-", 1, 0); 603 defaultdir = ostrcat(defaultdir, showname, 1, 0); 604 defaultdir = ostrcat(defaultdir, ".png", 1, 0); 605 606 debug(60, "defaultdir %s", defaultdir); 607 608 if(file_exist(defaultdir)) 609 { 610 debug(60, "defaultdir found"); 611 tmpskinpath = ostrcat(skinpath1, "titan-pluginpreview-", 0, 0); 612 tmpskinpath = ostrcat(tmpskinpath, showname, 1, 0); 613 tmpskinpath = ostrcat(tmpskinpath, ".png", 1, 0); 614 changepic(tmp, tmpskinpath); 615 free(tmpskinpath); tmpskinpath = NULL; 616 } 617 else 618 { 619 debug(60, "defaultdir not found use default.png"); 620 tmpskinpath = ostrcat("", "skin/plugin.png", 0, 0); 621 changepic(tmp, tmpskinpath); 622 free(tmpskinpath); tmpskinpath = NULL; 623 } 624 free(defaultdir); defaultdir = NULL; 625 626 if(defaultstr != NULL) 627 { 628 setlistboxselection(listbox, defaultstr); 629 // if(ostrcmp(defaultstr, (&ret1[i])->part) == 0) 630 // listbox->aktline = i + 1; 631 } 632 tmptitle = ostrcat(tmptitle, showname, 1, 0); 633 tmptitle = ostrcat(tmptitle, " v.", 1, 0); 634 tmptitle = ostrcat(tmptitle, node->version, 1, 0); 635 changetext(tmp, _(tmptitle)); 636 changename(tmp, tmptitle); 637 638 tmpinfo = ostrcat(tmpinfo, "\nSection: ", 1, 0); 639 tmpinfo = ostrcat(tmpinfo, node->section, 1, 0); 640 tmpinfo = ostrcat(tmpinfo, "\nDescription:\n", 1, 0); 641 if(node->desc != NULL) 642 tmpinfo = ostrcat(tmpinfo, node->desc, 1, 0); 643 else 644 tmpinfo = ostrcat(tmpinfo, _("no description found"), 1, 0); 645 changetext2(tmp, _(tmpinfo)); 646 647 free(tmpinfo); tmpinfo = NULL; 648 free(tmptitle); tmptitle = NULL; 649 free(tmpstr1);tmpstr1 = NULL; 650 free(showname);showname = NULL; 651 } 652 } 653 node = node->next; 654 } 655 } 656 listbox->aktpage = -1; 657 drawscreen(screen,0); 658 addscreenrc(screen, listbox); 659 660 while (1) 661 { 662 rcret = waitrc(screen, 0, 0); 663 664 if(rcret==getrcconfigint("rcexit",NULL)) break; 665 if(listbox->select != NULL && rcret==getrcconfigint("rcok",NULL)) 666 { 667 tmpstr = ostrcat(tmpstr, listbox->select->name, 1, 0); 668 break; 669 } 670 } 671 free(skinname1); skinname1 = NULL; 672 free(skinpath1); skinpath1 = NULL; 673 delownerrc(screen); 674 delmarkedscreennodes(screen, 1); 675 clearscreen(screen); 676 debug(1000, "out"); 677 return tmpstr; 678 679 } 680 681 char* get_ipk_tmpinstall(char* ipk) 682 { 683 debug(60, "in"); 684 685 char* cmd = NULL, *tmpstr = NULL; 686 cmd = ostrcat(cmd, "ipkg install /tmp/", 1, 0); 687 cmd = ostrcat(cmd, ipk, 1, 0); 688 689 tmpstr = command(cmd); 690 691 debug(60, "out %s",cmd); 692 free(cmd); cmd = NULL; 693 return tmpstr; 694 } 695 696 char* get_ipk_listinstall() 697 { 698 debug(60, "in"); 699 char* cmd = NULL, *tmpstr = NULL; 700 701 cmd = ostrcat(cmd, "ipkg list_installed | awk '{ print $1 }' | sed 's/Successfully//' | sed 's/titan-plugin-//'", 1, 0); 702 703 tmpstr = command(cmd); 704 705 debug(60, "out %s",cmd); 706 free(cmd); cmd = NULL; 707 return tmpstr; 708 } 709 710 char* get_ipk_tmplistinstall() 711 { 712 debug(60, "in"); 713 char* cmd = NULL, *tmpstr = NULL; 714 715 cmd = ostrcat(cmd, "ls /tmp | grep '.ipk'", 1, 0); 716 717 tmpstr = command(cmd); 718 719 debug(60, "out %s",cmd); 720 free(cmd); cmd = NULL; 721 return tmpstr; 722 } 723 724 char* get_ipk_remove(char* ipk) 725 { 726 debug(60, "in %s",ipk); 727 char* cmd = NULL, *tmpstr = NULL; 728 729 if(ipk == NULL) return NULL; 730 731 cmd = ostrcat(cmd, "ipkg remove titan-plugin-", 1, 0); 732 cmd = ostrcat(cmd, ipk, 1, 0); 733 734 tmpstr = command(cmd); 735 736 debug(60, "out"); 737 free(cmd); cmd = NULL; 738 return tmpstr; 739 } 740 741 char* get_ipk_info(char* section) 742 { 743 debug(60, "in %s",section); 744 char* cmd = NULL, *tmpstr = NULL; 745 746 if(section == NULL) return NULL; 747 748 cmd = ostrcat(cmd, "ipkg list *-", 1, 0); 749 cmd = ostrcat(cmd, section, 1, 0); 750 cmd = ostrcat(cmd, " | cut -d'-' -f6 | sed 's/Successfully terminated.//'", 1, 0); 751 752 tmpstr = command(cmd); 753 754 debug(60, "out %s",cmd); 755 free(cmd); cmd = NULL; 756 return tmpstr; 757 } 366 758 367 759 #endif
Note: See TracChangeset
for help on using the changeset viewer.