[Wepg-devel] mythcond/src PalmAppInfo.C,1.4,1.5 wepgsync.C,1.5,1.6
Brought to you by:
leonvs
|
From: Leon v. S. <le...@us...> - 2004-08-22 13:54:16
|
Update of /cvsroot/wepg/mythcond/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30880/src Modified Files: PalmAppInfo.C wepgsync.C Log Message: ok Index: wepgsync.C =================================================================== RCS file: /cvsroot/wepg/mythcond/src/wepgsync.C,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** wepgsync.C 8 Aug 2004 14:38:12 -0000 1.5 --- wepgsync.C 22 Aug 2004 13:53:53 -0000 1.6 *************** *** 71,74 **** --- 71,86 ---- } + static void + printDate(char* str, WepgDBTimeStamp const * ts) + { + sprintf(str, "%04li-%02li-%02li %02li:%02li", + ts->year, + ts->month, + ts->day, + ts->hour, + ts->minute + ); + } + *************** *** 163,167 **** IntermedRec::init( PalmAppInfo &appinfo, MYSQL *hostdb, MYSQL_RES *rs, MYSQL_ROW row ) { - WepgDBTimeStamp ts; struct tm tm; int fi; --- 175,178 ---- *************** *** 175,187 **** m_storage.station_id = atol( row[ mysql_field_index( rs, "chanid" ) ] ) - 1000; //HACK cat = row[ mysql_field_index( rs, "category" ) ]; ! i = 0; ! if (cat != NULL) ! while (i<APPNUMCATEGORIES) { ! if (strcmp(cat, appinfo.getPacked()->category_labels[i]) == 0) ! break; ! i++; } - m_storage.flags.category = i; parseDate( row[ mysql_field_index( rs, "starttime" ) ], &tm ); --- 186,199 ---- m_storage.station_id = atol( row[ mysql_field_index( rs, "chanid" ) ] ) - 1000; //HACK + m_storage.flags.category = 0; cat = row[ mysql_field_index( rs, "category" ) ]; ! if (cat != NULL) { ! for (i=0; i<APPNUMCATEGORIES; i++) { ! if (strcmp(cat, appinfo.getPacked()->category_labels[i]) == 0) { ! m_storage.flags.category = i; ! break; ! } ! } } parseDate( row[ mysql_field_index( rs, "starttime" ) ], &tm ); *************** *** 278,289 **** //some cache ! ts = m_storage.start_time; ! sprintf( m_startTimeStr, "%04li-%02li-%02li %02li:%02li", ! ts.year, ! ts.month, ! ts.day, ! ts.hour, ! ts.minute ! ); } --- 290,294 ---- //some cache ! printDate(m_startTimeStr, &m_storage.start_time); } *************** *** 343,346 **** --- 348,354 ---- int attr; int category; + char sql[1024]; + MYSQL_RES *rs; + MYSQL_ROW row; logprintf("wepg: saving modified recs\n"); *************** *** 373,377 **** } - retval = dlp_ReadRecordByIndex( pilot_socket, palmdb.getHandle(), --- 381,384 ---- *************** *** 384,388 **** continue; } - swapToHost( pacrec ); --- 391,394 ---- *************** *** 403,407 **** new_flags |= pacrec->flags.alarm ? FLAG_ALARM : 0; new_flags |= pacrec->flags.sys_seen_it ? FLAG_SYSSEENIT : 0; - new_flags |= pacrec->flags.unread ? FLAG_UNREAD : 0; new_flags |= pacrec->flags.record ? FLAG_RECORD : 0; --- 409,412 ---- *************** *** 409,430 **** new_flags |= pacrec->flags.recorded ? FLAG_RECORDED : 0; ! char sql[1024]; sprintf( sql, "UPDATE UserBroadcast " "SET user_rating=%i, flags=%i, rec_status=%i " "WHERE user_id=%i AND rec_id=%lu", - (int)pacrec->flags.user_rating, (int)new_flags, (int)STATUS_NONE, (int)hostuser.getInternalId(), - recid ); - free( pacrec ); - retval = mymysql_exec( hostdb, sql ); ! if ( retval ) return retval; } retval = dlp_ResetSyncFlags( pilot_socket, palmdb.getHandle() ); --- 414,480 ---- new_flags |= pacrec->flags.recorded ? FLAG_RECORDED : 0; ! int old_flags = 0; ! sprintf(sql, ! "SELECT flags FROM UserBroadcast " ! "WHERE user_id=%i AND rec_id=%lu", ! (int)hostuser.getInternalId(), ! recid); ! retval = mymysql_store(hostdb, sql, &rs); ! if (retval) { ! free(pacrec); ! return retval; ! } ! while( (row = mysql_fetch_row(rs)) != NULL ) { ! old_flags = atoi(row[0]); ! } ! mysql_free_result(rs); ! sprintf( sql, "UPDATE UserBroadcast " "SET user_rating=%i, flags=%i, rec_status=%i " "WHERE user_id=%i AND rec_id=%lu", (int)pacrec->flags.user_rating, (int)new_flags, (int)STATUS_NONE, (int)hostuser.getInternalId(), recid ); retval = mymysql_exec( hostdb, sql ); ! if ( retval ) { ! free(pacrec); return retval; + } + + if ((old_flags & FLAG_RECORD) != (new_flags & FLAG_RECORD)) { + char stim[64]; + printDate(stim, &pacrec->start_time); + int chanid = (int)(1000 + pacrec->station_id); //HACK + + if (new_flags & FLAG_RECORD) { + sprintf(sql, + "INSERT INTO record (type,chanid,station,starttime,startdate,endtime,enddate," + "title,subtitle,description,recpriority,recgroup,startoffset,endoffset) " + "SELECT DISTINCTROW " + "1,c.chanid,c.callsign,DATE_FORMAT(starttime,'%%T'),DATE_FORMAT(starttime,'%%Y-%%m-%%d'),DATE_FORMAT(endtime,'%%T'),DATE_FORMAT(endtime,'%%Y-%%m-%%d')," + "title, subtitle, description, 10, 'wepg', 0, 0 " + "FROM program AS p INNER JOIN channel AS c ON (p.chanid=c.chanid)" + "WHERE p.chanid=%i AND starttime='%s'", + chanid, + stim); + } + else { + sprintf(sql, + "DELETE FROM record " + "WHERE recgroup='wepg' AND chanid=%i AND " + "starttime=DATE_FORMAT('%s','%%T') AND startdate=DATE_FORMAT('%s','%%Y-%%m-%%d')", + chanid, stim, stim); + } + retval = mymysql_exec( hostdb, sql ); + if ( retval ) { + free( pacrec ); + return retval; + } + } + free(pacrec); } retval = dlp_ResetSyncFlags( pilot_socket, palmdb.getHandle() ); *************** *** 437,442 **** } - - static int archiveOldRecs( int pilot_socket, MYSQL *hostdb, --- 487,490 ---- *************** *** 610,613 **** --- 658,662 ---- } n_killed++; + } mysql_free_result( rs ); *************** *** 650,653 **** --- 699,703 ---- // mymysql_exec( hostdb, sql ); + // enum RecordingType{ kNotRecording = 0, kSingleRecord = 1, Index: PalmAppInfo.C =================================================================== RCS file: /cvsroot/wepg/mythcond/src/PalmAppInfo.C,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PalmAppInfo.C 7 Aug 2004 18:53:50 -0000 1.4 --- PalmAppInfo.C 22 Aug 2004 13:53:53 -0000 1.5 *************** *** 98,102 **** sprintf( sql, "SELECT chanid,callsign,channum " ! "FROM channel WHERE visible=1 ORDER BY channum" ); --- 98,105 ---- sprintf( sql, "SELECT chanid,callsign,channum " ! "FROM channel " ! "WHERE visible=1 AND chanid>=1000 AND chanid<2000 " ! // "ORDER BY channum" ! "ORDER BY chanid" //HACK: work-around for bug in palm app ); *************** *** 116,120 **** bool enabled = true; ! int listpos = atol( row[ mysql_field_index( rs, "channum" ) ] ); if ( listpos < 0 ) listpos = 0; if ( listpos >= APPNUMSTATIONS ) listpos = APPNUMSTATIONS-1; --- 119,123 ---- bool enabled = true; ! int listpos = stat_id;//HACK///atol( row[ mysql_field_index( rs, "channum" ) ] ); if ( listpos < 0 ) listpos = 0; if ( listpos >= APPNUMSTATIONS ) listpos = APPNUMSTATIONS-1; *************** *** 133,136 **** --- 136,140 ---- } + sprintf( sql, "SELECT DISTINCT category FROM program"); if ( mymysql_store( hostdb, sql, &rs ) ) { |