Changeset 16769
- Timestamp:
- 06/21/12 18:45:10 (11 years ago)
- Location:
- titan
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
titan/plugins/tmc/tmc.h
r16718 r16769 84 84 int count = 0; 85 85 struct mediadbfilter* node = mediadbfilterpos; 86 char* tmpstr = NULL ;86 char* tmpstr = NULL, *tmpfile = NULL; 87 87 88 88 tmcpicdel(tmcpictitle, tmcpicstar, tmcstatus, tmcpic1, tmcpic2, tmcpic3, tmcpic4, tmcpic5, tmcpictitlebg, tmcpicstarbg, tmcstatusbg, 0); … … 138 138 { 139 139 changepic(tmcpic3, tmpstr); 140 changeret(tmcpic3, node->node->file); 140 tmpfile = ostrcat(node->node->path, "/", 0, 0); 141 tmpfile = ostrcat(tmpfile, node->node->file, 1, 0); 142 tmpfile = addmountpart(tmpfile, 1); 143 changeret(tmcpic3, tmpfile); 144 free(tmpfile); tmpfile = NULL; 141 145 changetext(tmcpictitle, node->node->title); 142 146 … … 639 643 struct mediadb* node = NULL; 640 644 641 if(file != NULL) node = getmediadb(file, 0); 645 if(file != NULL) 646 { 647 char* dirname = ostrcat(file, NULL, 0, 0); 648 dirname = dirname(dirname); 649 node = getmediadb(dirname, basename(file), 0); 650 free(dirname); dirname = NULL; 651 } 642 652 643 653 if(menuid == 3) type = 0; //video … … 713 723 tmpstr = ostrcat(node->id, NULL, 0, 0); 714 724 715 node = createmediadb(node, tmpstr, type, title->ret, year->ret, released->ret, runtime->ret, genre->ret, director->ret, writer->ret, actors->ret, plot->ret, node->id, rating->ret, votes->ret, node-> file, title->ret, 0);725 node = createmediadb(node, tmpstr, type, title->ret, year->ret, released->ret, runtime->ret, genre->ret, director->ret, writer->ret, actors->ret, plot->ret, node->id, rating->ret, votes->ret, node->path, node->file, 0); 716 726 717 727 if(picret != NULL) … … 758 768 int ret = 0, tret = 0, width = 800, height = 300; 759 769 struct skin* tbox = getscreen("messagebox"); 760 char* tmpstr = NULL, *bg = NULL ;770 char* tmpstr = NULL, *bg = NULL, *tmpfile = NULL; 761 771 struct mediadb* node = NULL; 762 772 763 if(file != NULL) node = getmediadb(file, 0); 773 if(file != NULL) 774 { 775 char* dirname = ostrcat(file, NULL, 0, 0); 776 dirname = dirname(dirname); 777 node = getmediadb(dirname, basename(file), 0); 778 free(dirname); dirname = NULL; 779 } 764 780 765 781 if(node != NULL) … … 771 787 bg = savescreen(tbox); 772 788 773 tmpstr = ostrcat(_("Delete selected entry ?"), "\n\n", 0, 0); 774 tmpstr = ostrcat(tmpstr, node->file, 1, 0); 775 tmpstr = ostrcat(tmpstr, "\n\nOK = delete DB only\nRED = delete DB and file", 1, 0); 776 tret = textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("RED"), getrcconfigint("rcred", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, width, height, 0, 3); 777 free(tmpstr); tmpstr = NULL; 778 779 if(tret == 1) //del only DB 780 { 781 struct mediadbfilter* mf = mediadbfilterpos; 782 if(mediadbfilterpos != NULL) mediadbfilterpos = mediadbfilterpos->next; 783 delmediadbfilter(mf, 0); 784 delmediadb(node, 0); 785 status.writemediadb = 1; 786 ret = 1; 787 } 788 if(tret == 2) //del file and DB 789 { 790 struct mediadbfilter* mf = mediadbfilterpos; 791 if(mediadbfilterpos != NULL) mediadbfilterpos = mediadbfilterpos->next; 792 unlink(node->file); 793 delmediadbfilter(mf, 0); 794 delmediadb(node, 0); 795 status.writemediadb = 1; 796 ret = 1; 797 } 798 789 tmpfile = ostrcat(node->path, "/", 0, 0); 790 tmpfile = ostrcat(tmpfile, node->file, 1, 0); 791 tmpfile = addmountpart(tmpfile, 1); 792 793 if(tmpfile != NULL) 794 { 795 tmpstr = ostrcat(_("Delete selected entry ?"), "\n\n", 0, 0); 796 tmpstr = ostrcat(tmpstr, tmpfile, 1, 0); 797 tmpstr = ostrcat(tmpstr, "\n\nOK = delete DB only\nRED = delete DB and file", 1, 0); 798 tret = textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("RED"), getrcconfigint("rcred", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, width, height, 0, 3); 799 free(tmpstr); tmpstr = NULL; 800 801 if(tret == 1) //del only DB 802 { 803 struct mediadbfilter* mf = mediadbfilterpos; 804 if(mediadbfilterpos != NULL) mediadbfilterpos = mediadbfilterpos->next; 805 delmediadbfilter(mf, 0); 806 delmediadb(node, 0); 807 status.writemediadb = 1; 808 ret = 1; 809 } 810 if(tret == 2) //del file and DB 811 { 812 struct mediadbfilter* mf = mediadbfilterpos; 813 if(mediadbfilterpos != NULL) mediadbfilterpos = mediadbfilterpos->next; 814 unlink(tmpfile); 815 delmediadbfilter(mf, 0); 816 delmediadb(node, 0); 817 status.writemediadb = 1; 818 ret = 1; 819 } 820 } 821 822 free(tmpfile); tmpfile = NULL; 799 823 restorescreen(bg, tbox); 800 824 } … … 812 836 char* bg = NULL; 813 837 814 if(file != NULL) node = getmediadb(file, 0); 838 if(file != NULL) 839 { 840 char* dirname = ostrcat(file, NULL, 0, 0); 841 dirname = dirname(dirname); 842 node = getmediadb(dirname, basename(file), 0); 843 free(dirname); dirname = NULL; 844 } 845 815 846 if(node == NULL) return; 816 847 … … 840 871 841 872 if(tmdb != NULL) 842 node = createmediadb(node, tmdb->id, type, tmdb->title, tmdb->year, tmdb->released, tmdb->runtime, tmdb->genre, NULL, NULL, NULL, tmdb->plot, tmdb->id, tmdb->rating, tmdb->votes, node-> file, node->title, 0);873 node = createmediadb(node, tmdb->id, type, tmdb->title, tmdb->year, tmdb->released, tmdb->runtime, tmdb->genre, NULL, NULL, NULL, tmdb->plot, tmdb->id, tmdb->rating, tmdb->votes, node->path, node->file, 0); 843 874 844 875 clearscreen(tmcinfo); … … 866 897 struct mediadb* node = NULL; 867 898 868 if(file != NULL) node = getmediadb(file, 0); 899 if(file != NULL) 900 { 901 char* dirname = ostrcat(file, NULL, 0, 0); 902 dirname = dirname(dirname); 903 node = getmediadb(dirname, basename(file), 0); 904 free(dirname); dirname = NULL; 905 } 869 906 870 907 if(node != NULL) … … 1549 1586 if(mfilter->node != NULL) 1550 1587 { 1551 audioret = screenplay(mfilter->node->file, 0, 3); 1588 char* tmpfile = ostrcat(mfilter->node->path, "/", 0, 0); 1589 tmpfile = ostrcat(tmpfile, mfilter->node->file, 1, 0); 1590 tmpfile = addmountpart(tmpfile, 1); 1591 audioret = screenplay(tmpfile, 0, 3); 1592 free(tmpfile); tmpfile = NULL; 1552 1593 mediadbfilterpos = mfilter; 1553 1594 } … … 1583 1624 if(mfilter->node != NULL) 1584 1625 { 1585 picret = screentmcpicplay(mfilter->node->file); 1626 char* tmpfile = ostrcat(mfilter->node->path, "/", 0, 0); 1627 tmpfile = ostrcat(tmpfile, mfilter->node->file, 1, 0); 1628 tmpfile = addmountpart(tmpfile, 1); 1629 picret = screentmcpicplay(tmpfile); 1630 free(tmpfile); tmpfile = NULL; 1586 1631 mediadbfilterpos = mfilter; 1587 1632 } -
titan/titan/filelist.h
r16685 r16769 494 494 // struct mediadb* mnode = getmediadb(tmpstr, 0); 495 495 496 struct mediadb* mnode = getmediadb( filelist[i]->d_name, 1);496 struct mediadb* mnode = getmediadb(node->input, filelist[i]->d_name, 0); 497 497 free(tmpstr), tmpstr = NULL; 498 498 if(mnode != NULL) … … 614 614 615 615 // struct mediadb* mnode = getmediadb(tmpstr, 0); 616 struct mediadb* mnode = getmediadb( filelist[i]->d_name, 1);616 struct mediadb* mnode = getmediadb(node->input, filelist[i]->d_name, 0); 617 617 618 618 // free(tmpstr), tmpstr = NULL; -
titan/titan/global.h
r16701 r16769 1 1 #ifndef GLOBAL_H 2 2 #define GLOBAL_H 3 4 char* delmountpart(char* filename, int free1) 5 { 6 struct mntent ent; 7 FILE *fd = NULL; 8 char* ret = NULL, *buf = NULL; 9 10 if(filename == NULL) return NULL; 11 12 buf = malloc(MINMALLOC); 13 if(buf == NULL) 14 { 15 err("no mem"); 16 return NULL; 17 } 18 19 fd = setmntent("/proc/mounts", "r"); 20 if(fd != NULL) 21 { 22 while(getmntent_r(fd, &ent, buf, MINMALLOC) != 0) 23 { 24 if(ent.mnt_dir != NULL && strlen(ent.mnt_dir) > 1 && ostrstr(filename, ent.mnt_dir) == filename) 25 { 26 ret = string_replace(ent.mnt_dir, "", filename, free1); 27 free(buf); 28 return ret; 29 } 30 } 31 } 32 33 endmntent(fd); 34 free(buf); 35 return ret; 36 } 37 38 char* addmountpart(char* filename, int free1) 39 { 40 struct mntent ent; 41 FILE *fd = NULL; 42 char* ret = NULL, *buf = NULL; 43 44 if(filename == NULL) return NULL; 45 46 buf = malloc(MINMALLOC); 47 if(buf == NULL) 48 { 49 err("no mem"); 50 return NULL; 51 } 52 53 fd = setmntent("/proc/mounts", "r"); 54 if(fd != NULL) 55 { 56 while(getmntent_r(fd, &ent, buf, MINMALLOC)) 57 { 58 if(ent.mnt_dir != NULL && strlen(ent.mnt_dir) > 1) 59 { 60 ret = ostrcat(ent.mnt_dir, filename, 0, 0); 61 if(file_exist(ret)) 62 { 63 if(free1 == 1) free(filename); 64 free(buf); 65 return ret; 66 } 67 free(ret); ret = NULL; 68 } 69 } 70 } 71 72 endmntent(fd); 73 free(buf); 74 return ret; 75 } 3 76 4 77 struct blacklist* readblacklist(char* filename) … … 4510 4583 } 4511 4584 4512 char* ostrrstr(char* str, char* search, int len) 4585 //flag 0: search full str 4586 //flag 1: search only end of string 4587 char* ostrrstr(char* str, char* search, int len, int flag) 4513 4588 { 4514 4589 int slen = 0; … … 4522 4597 4523 4598 for(tmpstr = str + len - slen; tmpstr >= str; tmpstr--) 4599 { 4524 4600 if(strncmp(tmpstr, search, slen) == 0) 4525 4601 return tmpstr; 4602 if(flag == 1) return NULL; 4603 } 4526 4604 4527 4605 return NULL; … … 5027 5105 5028 5106 len = strlen(str); 5029 pos = ostrrstr(input, str, pos2 - input );5107 pos = ostrrstr(input, str, pos2 - input, 0); 5030 5108 if(pos == NULL) return NULL; 5031 5109 pos += len; -
titan/titan/mediadb.h
r16759 r16769 387 387 case 11: rating = tmpstr; break; 388 388 case 12: votes = tmpstr; break; 389 case 13: node->file = tmpstr; break; 390 case 14: timestamp = tmpstr; break; 391 case 15: flag = tmpstr; break; 389 case 13: node->path = tmpstr; break; 390 case 14: node->file = tmpstr; break; 391 case 15: timestamp = tmpstr; break; 392 case 16: flag = tmpstr; break; 392 393 } 393 394 … … 399 400 } 400 401 401 if(ret != 1 6)402 if(ret != 17) 402 403 { 403 404 if(count > 0) … … 451 452 452 453 status.writemediadb = 1; 453 modifymediadbcache(newnode-> file, newnode);454 modifymediadbcache(newnode->path, newnode->file, newnode); 454 455 455 456 if(last == NULL) … … 493 494 } 494 495 495 struct mediadb* createmediadb(struct mediadb* update, char* id, int type, char* title, char* year, char* released, char* runtime, char* genre, char* director, char* writer, char* actors, char* plot, char* poster, char* rating, char* votes, char* fullfile, char* file, int flag)496 struct mediadb* createmediadb(struct mediadb* update, char* id, int type, char* title, char* year, char* released, char* runtime, char* genre, char* director, char* writer, char* actors, char* plot, char* poster, char* rating, char* votes, char* path, char* file, int flag) 496 497 { 497 498 struct mediadb* mnode = NULL; 498 499 char* tmpstr = NULL; 499 500 500 if(fullfile == NULL) return NULL; 501 501 if(path == NULL || file == NULL) return NULL; 502 502 if(title == NULL) title = file; 503 503 … … 515 515 rating = stringreplacechar(rating, ',', '.'); 516 516 votes = stringreplacechar(votes, ',', '.'); 517 fullfile = stringreplacechar(fullfile, '#', ' '); 517 path = stringreplacechar(path, '#', ' '); 518 file = stringreplacechar(file, '#', ' '); 518 519 519 520 tmpstr = ostrcat(tmpstr, id, 1, 0); … … 545 546 if(votes != NULL) tmpstr = ostrcat(tmpstr, oitoa(atoi(votes)), 1, 1); 546 547 tmpstr = ostrcat(tmpstr, "#", 1, 0); 547 tmpstr = ostrcat(tmpstr, fullfile, 1, 0); 548 tmpstr = ostrcat(tmpstr, path, 1, 0); 549 tmpstr = ostrcat(tmpstr, "#", 1, 0); 550 tmpstr = ostrcat(tmpstr, file, 1, 0); 548 551 tmpstr = ostrcat(tmpstr, "#", 1, 0); 549 552 tmpstr = ostrcat(tmpstr, olutoa(time(NULL)), 1, 1); … … 554 557 { 555 558 m_lock(&status.mediadbmutex, 17); 556 delmediadbcache(update->file );559 delmediadbcache(update->file, update); 557 560 freemediadbcontent(update); 558 561 addmediadbcontent(update, tmpstr, strlen(tmpstr), 1); 559 modifymediadbcache(update-> file, update);562 modifymediadbcache(update->path, update->file, update); 560 563 m_unlock(&status.mediadbmutex, 17); 561 564 } … … 777 780 if(mfnode != NULL) 778 781 delmediadbfilter(mfnode, 1); 779 delmediadbcache(node->file );782 delmediadbcache(node->file, node); 780 783 freemediadbcontent(node); 781 784 … … 895 898 while(node != NULL) 896 899 { 897 ret = fprintf(fd, "%s#%d#%s#%d#%s#%s#%s#%s#%s#%s#%s#%s#%d#%d#%s#% lu#%d\n", node->id, node->type, node->title, node->year, node->released, node->runtime, node->genre, node->director, node->writer, node->actors, node->plot, node->poster, node->rating, node->votes, node->file, node->timestamp, node->flag);900 ret = fprintf(fd, "%s#%d#%s#%d#%s#%s#%s#%s#%s#%s#%s#%s#%d#%d#%s#%s#%lu#%d\n", node->id, node->type, node->title, node->year, node->released, node->runtime, node->genre, node->director, node->writer, node->actors, node->plot, node->poster, node->rating, node->votes, node->path, node->file, node->timestamp, node->flag); 898 901 899 902 if(ret < 0) … … 1392 1395 printf("start mediadbfindfilecb\n"); 1393 1396 int treffer = 0; 1394 char* tmpstr = NULL;1395 struct mediadb *node = mediadb;1397 char* shortpath = NULL, *tmpstr = NULL; 1398 struct mediadb *node = NULL; 1396 1399 1397 tmpstr = ostrcat(path, "/", 0, 0); 1398 tmpstr = ostrcat(tmpstr, file, 1, 0); 1400 shortpath = delmountpart(path, 0); 1399 1401 1400 1402 printf("start while\n"); 1403 m_lock(&status.mediadbmutex, 17); 1404 node = mediadb; 1401 1405 //check if entry exist 1402 1406 while(node != NULL) 1403 1407 { 1404 if(ostrcmp(node->file, tmpstr) == 0) 1405 { 1406 treffer = 1; 1407 break; 1408 } 1409 node = node->next; 1410 } 1408 if(ostrcmp(node->file, file) == 0) 1409 { 1410 //check directory 1411 if(ostrcmp(shortpath, node->path) == 0) //same file 1412 { 1413 treffer = 1; 1414 break; 1415 } 1416 1417 //check file size 1418 tmpstr = ostrcat(path, "/", 0, 0); 1419 tmpstr = ostrcat(tmpstr, file, 1, 0); 1420 off64_t s1 = getfilesize(tmpstr); 1421 free(tmpstr); tmpstr = NULL; 1422 1423 tmpstr = ostrcat(node->path, "/", 0, 0); 1424 tmpstr = ostrcat(tmpstr, node->file, 1, 0); 1425 tmpstr = addmountpart(tmpstr, 1); 1426 off64_t s2 = getfilesize(tmpstr); 1427 free(tmpstr); tmpstr = NULL; 1428 1429 if(s1 == s2) //seems the same file 1430 { 1431 treffer = 1; 1432 break; 1433 } 1434 } 1435 node = node->next; 1436 } 1437 m_unlock(&status.mediadbmutex, 17); 1411 1438 printf("end while\n"); 1412 1439 … … 1414 1441 1415 1442 if(treffer == 0 || (treffer == 1 && tout == 0) || (treffer == 1 && node != NULL && time(NULL) > node->timestamp + (tout * 86400))) 1416 1443 { 1417 1444 if(type == 0) 1418 1445 { … … 1573 1600 debug(133, "----------------------mediadb skipped----------------------"); 1574 1601 1575 debug(777, "add video: %s ", tmpstr);1602 debug(777, "add video: %s/%s", shortpath, file); 1576 1603 if(imdb != NULL) 1577 1604 { … … 1580 1607 printf("wo2.2\n"); 1581 1608 1582 createmediadb(node, imdb->id, type, imdb->title, imdb->year, imdb->released, imdb->runtime, imdb->genre, imdb->director, imdb->writer, imdb->actors, imdb->plot, imdb->id, imdb->rating, imdb->votes, tmpstr, file, 0);1609 createmediadb(node, imdb->id, type, imdb->title, imdb->year, imdb->released, imdb->runtime, imdb->genre, imdb->director, imdb->writer, imdb->actors, imdb->plot, imdb->id, imdb->rating, imdb->votes, shortpath, file, 0); 1583 1610 printf("wo2.3\n"); 1584 1611 … … 1587 1614 { 1588 1615 printf("wo2.0\n"); 1589 createmediadb(node, NULL, type, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tmpstr, file, 0);1616 createmediadb(node, NULL, type, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, shortpath, file, 0); 1590 1617 } 1591 1618 printf("wo3\n"); … … 1622 1649 else if(type == 1) 1623 1650 { 1624 debug(777, "add audio: %s ", tmpstr);1625 createmediadb(node, NULL, type, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tmpstr, file, 0);1651 debug(777, "add audio: %s/%s", shortpath, file); 1652 createmediadb(node, NULL, type, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, shortpath, file, 0); 1626 1653 } 1627 1654 else if(type == 2) … … 1629 1656 char* thumbfile = NULL; 1630 1657 1631 debug(777, "add pic: %s ", tmpstr);1658 debug(777, "add pic: %s/%s", shortpath, file); 1632 1659 if(status.thumbthread != NULL) 1633 1660 { … … 1643 1670 } 1644 1671 1645 createmediadb(node, NULL, type, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, thumbfile, NULL, NULL, tmpstr, file, 0);1672 createmediadb(node, NULL, type, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, thumbfile, NULL, NULL, shortpath, file, 0); 1646 1673 free(thumbfile); thumbfile = NULL; 1647 1674 } 1648 1675 } 1649 free( tmpstr); tmpstr= NULL;1676 free(shortpath); shortpath = NULL; 1650 1677 } 1651 1678 -
titan/titan/mediadbcache.h
r16606 r16769 22 22 } 23 23 24 // flag 0 path + file25 // flag 1 file26 struct mediadb* getmediadb(char* file, int flag)24 // flag 0: path + file 25 // flag 1: file 26 struct mediadb* getmediadb(char* path, char* file, int flag) 27 27 { 28 28 unsigned int hash; … … 37 37 while(node != NULL) 38 38 { 39 if( flag == 0 &&ostrcmp(file, node->file) == 0)39 if(ostrcmp(file, node->file) == 0) 40 40 { 41 m_unlock(&status.mediadbmutex, 17);42 return node->mediadbnode;43 }44 else if(flag == 1 && ostrcmp(file, basename(node->file)) == 0)45 {41 if(flag == 0 && ostrrstr(path, node->path, -1, 1) == NULL) 42 { 43 node = node->next; 44 continue; 45 } 46 46 m_unlock(&status.mediadbmutex, 17); 47 47 return node->mediadbnode; … … 55 55 } 56 56 57 struct mediadbcache* modifymediadbcache(char* file, struct mediadb* mnode)57 struct mediadbcache* modifymediadbcache(char* path, char* file, struct mediadb* mnode) 58 58 { 59 59 unsigned int hash; … … 73 73 //TODO: copy file??? 74 74 newnode->file = file; 75 newnode->path = path; 75 76 newnode->mediadbnode = mnode; 76 77 … … 97 98 } 98 99 99 void delmediadbcache(char* file )100 void delmediadbcache(char* file, struct mediadb* mnode) 100 101 { 101 102 unsigned int hash; … … 109 110 while(node != NULL) 110 111 { 111 if( ostrcmp(file, node->file) == 0)112 if(node->mediadbnode == mnode) 112 113 { 113 114 if(node == mediadbcache[hash]) -
titan/titan/struct.h
r16683 r16769 61 61 #include <sys/utsname.h> 62 62 #include <regex.h> 63 #include <mntent.h> 63 64 64 65 #define IPKG_LIB … … 290 291 int rating; 291 292 int votes; 293 char* path; 292 294 char* file; 293 295 time_t timestamp; … … 299 301 struct mediadbcache 300 302 { 303 char* path; 301 304 char* file; 302 305 struct mediadb* mediadbnode;
Note: See TracChangeset
for help on using the changeset viewer.