diff --git a/src/org/mythtv/client/ui/MainMenuFragment.java b/src/org/mythtv/client/ui/MainMenuFragment.java index 2f1d14f0..3fa7ac19 100644 --- a/src/org/mythtv/client/ui/MainMenuFragment.java +++ b/src/org/mythtv/client/ui/MainMenuFragment.java @@ -309,6 +309,14 @@ public void onResume() { //get connected location profile LocationProfile profile = this.mLocationProfileDaoHelper.findConnectedProfile(this.getActivity()); + if( null == profile ) { + List profiles = mLocationProfileDaoHelper.findAll( getActivity() ); + if( profiles.size() == 1 ) { + profile = profiles.get( 0 ); + + mLocationProfileDaoHelper.setConnectedLocationProfile( getActivity(), profile.getId() ); + } + } //get away/home toggle ToggleButton toggleIsAway = (ToggleButton)this.getActivity().findViewById(R.id.toggleButtonIsAway); diff --git a/src/org/mythtv/client/ui/dvr/ProgramGroupFragment.java b/src/org/mythtv/client/ui/dvr/ProgramGroupFragment.java index cd26d043..12198f48 100644 --- a/src/org/mythtv/client/ui/dvr/ProgramGroupFragment.java +++ b/src/org/mythtv/client/ui/dvr/ProgramGroupFragment.java @@ -85,7 +85,7 @@ public Loader onCreateLoader( int id, Bundle args ) { LocationProfile locationProfile = mLocationProfileDaoHelper.findConnectedProfile( getActivity() ); String[] projection = { ProgramConstants._ID, ProgramConstants.FIELD_TITLE, ProgramConstants.FIELD_SUB_TITLE, ProgramConstants.FIELD_CATEGORY, ProgramConstants.FIELD_START_TIME }; - String selection = ProgramConstants.FIELD_TITLE + " = ? AND " + ProgramConstants.TABLE_NAME_RECORDED + "." + ProgramConstants.FIELD_HOSTNAME + " = ? AND " + ProgramConstants.TABLE_NAME_RECORDED + "." + ProgramConstants.FIELD_IN_ERROR + " = ?"; + String selection = ProgramConstants.FIELD_TITLE + " = ? AND " + ProgramConstants.TABLE_NAME_RECORDED + "." + ProgramConstants.FIELD_MASTER_HOSTNAME + " = ? AND " + ProgramConstants.TABLE_NAME_RECORDED + "." + ProgramConstants.FIELD_IN_ERROR + " = ?"; String[] selectionArgs = { ( null != programGroup && null != programGroup.getTitle() ? programGroup.getTitle() : "" ), locationProfile.getHostname(), "0" }; CursorLoader cursorLoader = new CursorLoader( getActivity(), ProgramConstants.CONTENT_URI_RECORDED, projection, selection, selectionArgs, ProgramConstants.FIELD_SEASON + " DESC ," + ProgramConstants.FIELD_EPISODE + " DESC" ); diff --git a/src/org/mythtv/client/ui/dvr/RecordingsFragment.java b/src/org/mythtv/client/ui/dvr/RecordingsFragment.java index 2dea073e..2189aeee 100644 --- a/src/org/mythtv/client/ui/dvr/RecordingsFragment.java +++ b/src/org/mythtv/client/ui/dvr/RecordingsFragment.java @@ -101,7 +101,7 @@ public Loader onCreateLoader( int id, Bundle args ) { Log.v( TAG, "onCreateLoader : enter" ); String[] projection = null; - String selection = ProgramGroupConstants.FIELD_HOSTNAME + " = ?"; + String selection = ProgramGroupConstants.FIELD_MASTER_HOSTNAME + " = ?"; String[] selectionArgs = new String[] { mLocationProfile.getHostname() }; String sortOrder = ProgramGroupConstants.FIELD_PROGRAM_GROUP; @@ -420,7 +420,7 @@ public void onReceive( Context context, Intent intent ) { LocationProfile profile = mLocationProfileDaoHelper.findConnectedProfile( getActivity() ); boolean inError = false; - Cursor errorCursor = getActivity().getContentResolver().query( ProgramConstants.CONTENT_URI_RECORDED, new String[] { ProgramConstants._ID }, ProgramConstants.TABLE_NAME_RECORDED + "." + ProgramConstants.FIELD_IN_ERROR + " = ? AND " + ProgramConstants.TABLE_NAME_RECORDED + "." + ProgramConstants.FIELD_HOSTNAME + " = ?", new String[] { "1", profile.getHostname() }, null ); + Cursor errorCursor = getActivity().getContentResolver().query( ProgramConstants.CONTENT_URI_RECORDED, new String[] { ProgramConstants._ID }, ProgramConstants.TABLE_NAME_RECORDED + "." + ProgramConstants.FIELD_IN_ERROR + " = ? AND " + ProgramConstants.TABLE_NAME_RECORDED + "." + ProgramConstants.FIELD_MASTER_HOSTNAME + " = ?", new String[] { "1", profile.getHostname() }, null ); if( errorCursor.moveToFirst() ) { inError = true; } diff --git a/src/org/mythtv/client/ui/dvr/UpcomingFragment.java b/src/org/mythtv/client/ui/dvr/UpcomingFragment.java index 855239c6..6fc49b34 100644 --- a/src/org/mythtv/client/ui/dvr/UpcomingFragment.java +++ b/src/org/mythtv/client/ui/dvr/UpcomingFragment.java @@ -95,7 +95,7 @@ public Loader onCreateLoader( int id, Bundle args ) { String selection = ProgramConstants.TABLE_NAME_UPCOMING + "." + ProgramConstants.FIELD_START_TIME + " >= ? AND " + ProgramConstants.TABLE_NAME_UPCOMING + "." + ProgramConstants.FIELD_START_TIME + " < ? AND " + ProgramConstants.TABLE_NAME_UPCOMING + "." + ProgramConstants.FIELD_START_TIME + " >= ? AND " + - ProgramConstants.TABLE_NAME_UPCOMING + "." + ProgramConstants.FIELD_HOSTNAME + " = ?"; + ProgramConstants.TABLE_NAME_UPCOMING + "." + ProgramConstants.FIELD_MASTER_HOSTNAME + " = ?"; String[] selectionArgs = new String[] { String.valueOf( startDay.getMillis() ), String.valueOf( endDay.getMillis() ), String.valueOf( now.getMillis() ), locationProfile.getHostname() }; diff --git a/src/org/mythtv/db/AbstractBaseConstants.java b/src/org/mythtv/db/AbstractBaseConstants.java index 7fb046e7..25433588 100644 --- a/src/org/mythtv/db/AbstractBaseConstants.java +++ b/src/org/mythtv/db/AbstractBaseConstants.java @@ -32,7 +32,7 @@ public abstract class AbstractBaseConstants implements BaseColumns { public static final String FIELD_ID_DATA_TYPE = "INTEGER"; public static final String FIELD_ID_PRIMARY_KEY = "PRIMARY KEY AUTOINCREMENT"; - public static final String FIELD_HOSTNAME = "HOSTNAME"; - public static final String FIELD_HOSTNAME_DATA_TYPE = "TEXT"; + public static final String FIELD_MASTER_HOSTNAME = "MASTER_HOSTNAME"; + public static final String FIELD_MASTER_HOSTNAME_DATA_TYPE = "TEXT"; } diff --git a/src/org/mythtv/db/AbstractDaoHelper.java b/src/org/mythtv/db/AbstractDaoHelper.java index 514a3c72..7d1f3706 100644 --- a/src/org/mythtv/db/AbstractDaoHelper.java +++ b/src/org/mythtv/db/AbstractDaoHelper.java @@ -39,7 +39,7 @@ protected AbstractDaoHelper() { } protected String appendLocationHostname( final Context context, final LocationProfile locationProfile, String selection, String table ) { - return ( !TextUtils.isEmpty( table ) ? ( table + "." ) : "" ) + AbstractBaseConstants.FIELD_HOSTNAME + return ( !TextUtils.isEmpty( table ) ? ( table + "." ) : "" ) + AbstractBaseConstants.FIELD_MASTER_HOSTNAME + " = '" + locationProfile.getHostname() + "'" diff --git a/src/org/mythtv/db/DatabaseHelper.java b/src/org/mythtv/db/DatabaseHelper.java index 8f39af11..090b615d 100644 --- a/src/org/mythtv/db/DatabaseHelper.java +++ b/src/org/mythtv/db/DatabaseHelper.java @@ -48,7 +48,7 @@ public class DatabaseHelper extends SQLiteOpenHelper { private static final String TAG = DatabaseHelper.class.getSimpleName(); private static final String DATABASE_NAME = "mythtvdb"; - private static final int DATABASE_VERSION = 105; + private static final int DATABASE_VERSION = 107; public DatabaseHelper( Context context ) { super( context, DATABASE_NAME, null, DATABASE_VERSION ); @@ -110,8 +110,8 @@ public void onCreate( SQLiteDatabase db ) { public void onUpgrade( SQLiteDatabase db, int oldVersion, int newVersion ) { Log.v( TAG, "onUpgrade : enter" ); - if( oldVersion < 105 ) { - Log.v( TAG, "onUpgrade : upgrading to db version 105" ); + if( oldVersion < 107 ) { + Log.v( TAG, "onUpgrade : upgrading to db version 107" ); onCreate( db ); @@ -204,7 +204,7 @@ private void createEtag( SQLiteDatabase db ) { sqlBuilder.append( EtagConstants.FIELD_VALUE ).append( " " ).append( EtagConstants.FIELD_VALUE_DATA_TYPE ).append( ", " ); sqlBuilder.append( EtagConstants.FIELD_DATA_ID ).append( " " ).append( EtagConstants.FIELD_DATA_ID_DATA_TYPE ).append( " default" ).append( EtagConstants.FIELD_DATA_ID_DEFAULT ).append( ", " ); sqlBuilder.append( EtagConstants.FIELD_DATE ).append( " " ).append( EtagConstants.FIELD_DATE_DATA_TYPE ).append( ", " ); - sqlBuilder.append( EtagConstants.FIELD_HOSTNAME ).append( " " ).append( EtagConstants.FIELD_HOSTNAME_DATA_TYPE ); + sqlBuilder.append( EtagConstants.FIELD_MASTER_HOSTNAME ).append( " " ).append( EtagConstants.FIELD_MASTER_HOSTNAME_DATA_TYPE ); sqlBuilder.append( ");" ); String sql = sqlBuilder.toString(); if( Log.isLoggable( TAG, Log.VERBOSE ) ) { @@ -489,7 +489,8 @@ private void createProgram( SQLiteDatabase db, String tableName ) { sqlBuilder.append( ProgramConstants.FIELD_EPISODE ).append( " " ).append( ProgramConstants.FIELD_EPISODE_DATA_TYPE ).append( ", " ); sqlBuilder.append( ProgramConstants.FIELD_CHANNEL_ID ).append( " " ).append( ProgramConstants.FIELD_CHANNEL_ID_DATA_TYPE ).append( ", " ); sqlBuilder.append( ProgramConstants.FIELD_RECORD_ID ).append( " " ).append( ProgramConstants.FIELD_RECORD_ID_DATA_TYPE ).append( ", " ); - sqlBuilder.append( ProgramConstants.FIELD_IN_ERROR ).append( " " ).append( ProgramConstants.FIELD_IN_ERROR_DATA_TYPE ); + sqlBuilder.append( ProgramConstants.FIELD_IN_ERROR ).append( " " ).append( ProgramConstants.FIELD_IN_ERROR_DATA_TYPE ).append( ", " ); + sqlBuilder.append( ProgramConstants.FIELD_MASTER_HOSTNAME ).append( " " ).append( ProgramConstants.FIELD_MASTER_HOSTNAME_DATA_TYPE ); sqlBuilder.append( ");" ); String sql = sqlBuilder.toString(); if( Log.isLoggable( TAG, Log.VERBOSE ) ) { @@ -542,8 +543,8 @@ private void createChannel( SQLiteDatabase db ) { sqlBuilder.append( ChannelConstants.FIELD_VISIBLE ).append( " " ).append( ChannelConstants.FIELD_VISIBLE_DATA_TYPE ).append( " default " ).append( ChannelConstants.FIELD_VISIBLE_DEFAULT ).append( ", " ); sqlBuilder.append( ChannelConstants.FIELD_XMLTV_ID ).append( " " ).append( ChannelConstants.FIELD_XMLTV_ID_DATA_TYPE ).append( ", " ); sqlBuilder.append( ChannelConstants.FIELD_DEFAULT_AUTH ).append( " " ).append( ChannelConstants.FIELD_DEFAULT_AUTH_DATA_TYPE ).append( ", " ); - sqlBuilder.append( ChannelConstants.FIELD_HOSTNAME ).append( " " ).append( ChannelConstants.FIELD_HOSTNAME_DATA_TYPE ).append( ", " ); - sqlBuilder.append( "UNIQUE(" ).append( ChannelConstants.FIELD_CHAN_ID ).append( ", " ).append( ChannelConstants.FIELD_HOSTNAME ).append( ")" ); + sqlBuilder.append( ChannelConstants.FIELD_MASTER_HOSTNAME ).append( " " ).append( ChannelConstants.FIELD_MASTER_HOSTNAME_DATA_TYPE ).append( ", " ); + sqlBuilder.append( "UNIQUE(" ).append( ChannelConstants.FIELD_CHAN_ID ).append( ", " ).append( ChannelConstants.FIELD_MASTER_HOSTNAME ).append( ")" ); sqlBuilder.append( ");" ); String sql = sqlBuilder.toString(); if( Log.isLoggable( TAG, Log.VERBOSE ) ) { @@ -572,7 +573,7 @@ private void createProgramGroup( SQLiteDatabase db ) { sqlBuilder.append( ProgramGroupConstants.FIELD_TITLE ).append( " " ).append( ProgramGroupConstants.FIELD_TITLE_DATA_TYPE ).append( ", " ); sqlBuilder.append( ProgramGroupConstants.FIELD_CATEGORY ).append( " " ).append( ProgramGroupConstants.FIELD_CATEGORY_DATA_TYPE ).append( ", " ); sqlBuilder.append( ProgramGroupConstants.FIELD_INETREF ).append( " " ).append( ProgramGroupConstants.FIELD_INETREF_DATA_TYPE ).append( ", " ); - sqlBuilder.append( ProgramGroupConstants.FIELD_HOSTNAME ).append( " " ).append( ProgramGroupConstants.FIELD_HOSTNAME_DATA_TYPE ); + sqlBuilder.append( ProgramGroupConstants.FIELD_MASTER_HOSTNAME ).append( " " ).append( ProgramGroupConstants.FIELD_MASTER_HOSTNAME_DATA_TYPE ); sqlBuilder.append( ");" ); String sql = sqlBuilder.toString(); if( Log.isLoggable( TAG, Log.VERBOSE ) ) { @@ -612,8 +613,8 @@ private void createRecording( SQLiteDatabase db ) { sqlBuilder.append( RecordingConstants.FIELD_PROFILE ).append( " " ).append( RecordingConstants.FIELD_PROFILE_DATA_TYPE ).append( ", " ); sqlBuilder.append( RecordingConstants.FIELD_PROGRAM_ID ).append( " " ).append( RecordingConstants.FIELD_PROGRAM_ID_DATA_TYPE ).append( ", " ); sqlBuilder.append( RecordingConstants.FIELD_START_TIME ).append( " " ).append( RecordingConstants.FIELD_START_TIME_DATA_TYPE ).append( ", " ); - sqlBuilder.append( RecordingConstants.FIELD_HOSTNAME ).append( " " ).append( RecordingConstants.FIELD_HOSTNAME ).append( ", " ); - sqlBuilder.append( "UNIQUE(" ).append( RecordingConstants.FIELD_RECORD_ID ).append( ", " ).append( RecordingConstants.FIELD_START_TIME ).append( ", " ).append( RecordingConstants.FIELD_HOSTNAME ).append( ")" ); + sqlBuilder.append( RecordingConstants.FIELD_MASTER_HOSTNAME ).append( " " ).append( RecordingConstants.FIELD_MASTER_HOSTNAME ).append( ", " ); + sqlBuilder.append( "UNIQUE(" ).append( RecordingConstants.FIELD_RECORD_ID ).append( ", " ).append( RecordingConstants.FIELD_START_TIME ).append( ", " ).append( RecordingConstants.FIELD_MASTER_HOSTNAME ).append( ")" ); sqlBuilder.append( ");" ); String sql = sqlBuilder.toString(); if( Log.isLoggable( TAG, Log.VERBOSE ) ) { @@ -663,8 +664,8 @@ private void createLiveStream( SQLiteDatabase db ) { sqlBuilder.append( LiveStreamConstants.FIELD_AUDIO_ONLY_BITRATE ).append( " " ).append( LiveStreamConstants.FIELD_AUDIO_ONLY_BITRATE_DATA_TYPE ).append( ", " ); sqlBuilder.append( LiveStreamConstants.FIELD_START_TIME ).append( " " ).append( LiveStreamConstants.FIELD_START_TIME_DATA_TYPE ).append( ", " ); sqlBuilder.append( LiveStreamConstants.FIELD_CHAN_ID ).append( " " ).append( LiveStreamConstants.FIELD_CHAN_ID_DATA_TYPE ).append( ", " ); - sqlBuilder.append( LiveStreamConstants.FIELD_HOSTNAME ).append( " " ).append( LiveStreamConstants.FIELD_HOSTNAME ).append( ", " ); - sqlBuilder.append( "UNIQUE(" ).append( LiveStreamConstants.FIELD_START_TIME ).append( ", " ).append( LiveStreamConstants.FIELD_CHAN_ID ).append( ", " ).append( LiveStreamConstants.FIELD_HOSTNAME ).append( ")" ); + sqlBuilder.append( LiveStreamConstants.FIELD_MASTER_HOSTNAME ).append( " " ).append( LiveStreamConstants.FIELD_MASTER_HOSTNAME ).append( ", " ); + sqlBuilder.append( "UNIQUE(" ).append( LiveStreamConstants.FIELD_START_TIME ).append( ", " ).append( LiveStreamConstants.FIELD_CHAN_ID ).append( ", " ).append( LiveStreamConstants.FIELD_MASTER_HOSTNAME ).append( ")" ); sqlBuilder.append( ");" ); String sql = sqlBuilder.toString(); if( Log.isLoggable( TAG, Log.VERBOSE ) ) { diff --git a/src/org/mythtv/db/channel/ChannelConstants.java b/src/org/mythtv/db/channel/ChannelConstants.java index 7cc1da08..51fd2155 100644 --- a/src/org/mythtv/db/channel/ChannelConstants.java +++ b/src/org/mythtv/db/channel/ChannelConstants.java @@ -153,7 +153,7 @@ public class ChannelConstants extends AbstractBaseConstants { sb.append( FIELD_VISIBLE ).append( "," ); sb.append( FIELD_XMLTV_ID ).append( "," ); sb.append( FIELD_DEFAULT_AUTH ).append( "," ); - sb.append( FIELD_HOSTNAME ); + sb.append( FIELD_MASTER_HOSTNAME ); sb.append( " ) " ); sb.append( "VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )" ); diff --git a/src/org/mythtv/db/channel/ChannelDaoHelper.java b/src/org/mythtv/db/channel/ChannelDaoHelper.java index f4929baa..68cdc098 100644 --- a/src/org/mythtv/db/channel/ChannelDaoHelper.java +++ b/src/org/mythtv/db/channel/ChannelDaoHelper.java @@ -557,8 +557,8 @@ public ChannelInfo convertCursorToChannelInfo( Cursor cursor ) { defaultAuth = cursor.getString( cursor.getColumnIndex( ChannelConstants.TABLE_NAME + "_" + ChannelConstants.FIELD_DEFAULT_AUTH ) ); } - if( cursor.getColumnIndex( ChannelConstants.TABLE_NAME + "_" + ChannelConstants.FIELD_HOSTNAME ) != -1 ) { - Log.v( TAG, "convertCursorToChannelInfo : hostname" + cursor.getString( cursor.getColumnIndex( ChannelConstants.TABLE_NAME + "_" + ChannelConstants.FIELD_HOSTNAME ) ) ); + if( cursor.getColumnIndex( ChannelConstants.TABLE_NAME + "_" + ChannelConstants.FIELD_MASTER_HOSTNAME ) != -1 ) { + Log.v( TAG, "convertCursorToChannelInfo : hostname" + cursor.getString( cursor.getColumnIndex( ChannelConstants.TABLE_NAME + "_" + ChannelConstants.FIELD_MASTER_HOSTNAME ) ) ); } ChannelInfo channelInfo = new ChannelInfo(); @@ -652,7 +652,7 @@ private ContentValues convertChannelInfoToContentValues( final Context context, values.put( ChannelConstants.FIELD_VISIBLE, ( channelInfo.isVisable() ? 1 : 0 ) ); values.put( ChannelConstants.FIELD_XMLTV_ID, channelInfo.getXmltvId() ); values.put( ChannelConstants.FIELD_DEFAULT_AUTH, channelInfo.getDefaultAuth() ); - values.put( ChannelConstants.FIELD_HOSTNAME, locationProfile.getHostname() ); + values.put( ChannelConstants.FIELD_MASTER_HOSTNAME, locationProfile.getHostname() ); // Log.v( TAG, "convertChannelToContentValues : exit" ); return values; diff --git a/src/org/mythtv/db/content/LiveStreamDaoHelper.java b/src/org/mythtv/db/content/LiveStreamDaoHelper.java index 2764dff8..9f983ea7 100644 --- a/src/org/mythtv/db/content/LiveStreamDaoHelper.java +++ b/src/org/mythtv/db/content/LiveStreamDaoHelper.java @@ -211,7 +211,7 @@ public int save( final Context context, final LocationProfile locationProfile, L if( null == context ) throw new RuntimeException( "LiveStreamDaoHelper is not initialized" ); - ContentValues values = convertLiveStreamInfoToContentValues( context, locationProfile, liveStreamInfo, program ); + ContentValues values = convertLiveStreamInfoToContentValues( locationProfile, liveStreamInfo, program ); String[] projection = new String[] { LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants._ID }; String selection = LiveStreamConstants.FIELD_ID + " = ?"; @@ -427,8 +427,8 @@ public LiveStreamInfo convertCursorToLiveStreamInfo( Cursor cursor ) { Log.v( TAG, "convertCursorToLiveStreamInfo : startTime=" + new DateTime( cursor.getLong( cursor.getColumnIndex( LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants.FIELD_START_TIME ) ) ) ); } - if( cursor.getColumnIndex( LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants.FIELD_HOSTNAME ) != -1 ) { - Log.v( TAG, "convertCursorToLiveStreamInfo : hostname=" + cursor.getString( cursor.getColumnIndex( LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants.FIELD_HOSTNAME ) ) ); + if( cursor.getColumnIndex( LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants.FIELD_MASTER_HOSTNAME ) != -1 ) { + Log.v( TAG, "convertCursorToLiveStreamInfo : hostname=" + cursor.getString( cursor.getColumnIndex( LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants.FIELD_MASTER_HOSTNAME ) ) ); } LiveStreamInfo liveStreamInfo = new LiveStreamInfo(); @@ -488,7 +488,7 @@ private ContentValues[] convertLiveStreamInfosToContentValuesArray( final Contex channelInfo.setChannelId( channelId ); program.setChannelInfo( channelInfo ); - contentValues = convertLiveStreamInfoToContentValues( context, locationProfile, liveStreamInfo, program ); + contentValues = convertLiveStreamInfoToContentValues( locationProfile, liveStreamInfo, program ); contentValuesArray.add( contentValues ); } @@ -505,7 +505,7 @@ private ContentValues[] convertLiveStreamInfosToContentValuesArray( final Contex return null; } - private ContentValues convertLiveStreamInfoToContentValues( final Context context, final LocationProfile locationProfile, final LiveStreamInfo liveStreamInfo, final Program program ) { + private ContentValues convertLiveStreamInfoToContentValues( final LocationProfile locationProfile, final LiveStreamInfo liveStreamInfo, final Program program ) { // Log.v( TAG, "convertLiveStreamToContentValues : enter" ); ContentValues values = new ContentValues(); @@ -534,7 +534,7 @@ private ContentValues convertLiveStreamInfoToContentValues( final Context contex values.put( LiveStreamConstants.FIELD_AUDIO_ONLY_BITRATE, liveStreamInfo.getAudioOnlyBitrate() ); values.put( LiveStreamConstants.FIELD_CHAN_ID, program.getChannelInfo().getChannelId() ); values.put( LiveStreamConstants.FIELD_START_TIME, program.getStartTime().getMillis() ); - values.put( LiveStreamConstants.FIELD_HOSTNAME, locationProfile.getHostname() ); + values.put( LiveStreamConstants.FIELD_MASTER_HOSTNAME, locationProfile.getHostname() ); // Log.v( TAG, "convertLiveStreamToContentValues : exit" ); return values; diff --git a/src/org/mythtv/db/dvr/ProgramConstants.java b/src/org/mythtv/db/dvr/ProgramConstants.java index 04a12116..5232e793 100644 --- a/src/org/mythtv/db/dvr/ProgramConstants.java +++ b/src/org/mythtv/db/dvr/ProgramConstants.java @@ -89,6 +89,9 @@ public class ProgramConstants extends AbstractBaseConstants { public static final String FIELD_PROGRAM_FLAGS = "PROGRAM_FLAGS"; public static final String FIELD_PROGRAM_FLAGS_DATA_TYPE = "TEXT"; + public static final String FIELD_HOSTNAME = "HOSTNAME"; + public static final String FIELD_HOSTNAME_DATA_TYPE = "TEXT"; + public static final String FIELD_FILENAME = "FILENAME"; public static final String FIELD_FILENAME_DATA_TYPE = "TEXT"; @@ -120,7 +123,7 @@ public class ProgramConstants extends AbstractBaseConstants { FIELD_START_TIME, FIELD_END_TIME, FIELD_TITLE, FIELD_SUB_TITLE, FIELD_CATEGORY, FIELD_CATEGORY_TYPE, FIELD_REPEAT, FIELD_VIDEO_PROPS, FIELD_AUDIO_PROPS, FIELD_SUB_PROPS, FIELD_SERIES_ID, FIELD_PROGRAM_ID, FIELD_STARS, FIELD_FILE_SIZE, FIELD_LAST_MODIFIED, FIELD_PROGRAM_FLAGS, FIELD_HOSTNAME, FIELD_FILENAME, FIELD_AIR_DATE, FIELD_DESCRIPTION, - FIELD_INETREF, FIELD_SEASON, FIELD_EPISODE, FIELD_CHANNEL_ID, FIELD_RECORD_ID, FIELD_IN_ERROR + FIELD_INETREF, FIELD_SEASON, FIELD_EPISODE, FIELD_CHANNEL_ID, FIELD_RECORD_ID, FIELD_IN_ERROR, FIELD_MASTER_HOSTNAME }; static { @@ -150,11 +153,12 @@ public class ProgramConstants extends AbstractBaseConstants { insert.append( FIELD_EPISODE ).append( "," ); insert.append( FIELD_CHANNEL_ID ).append( ", " ); insert.append( FIELD_RECORD_ID ).append( ", " ); - insert.append( FIELD_IN_ERROR ); + insert.append( FIELD_IN_ERROR ).append( ", " ); + insert.append( FIELD_MASTER_HOSTNAME ); StringBuilder values = new StringBuilder(); values.append( " ) " ); - values.append( "VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )" ); + values.append( "VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )" ); StringBuilder insertProgram = new StringBuilder(); insertProgram.append( "INSERT INTO " ).append( TABLE_NAME_PROGRAM ).append( " ( " ); @@ -199,6 +203,7 @@ public class ProgramConstants extends AbstractBaseConstants { update.append( FIELD_RECORD_ID ).append( " = ?, " ); update.append( FIELD_HOSTNAME ).append( "= ?" ); update.append( FIELD_IN_ERROR ).append( "= ?" ); + update.append( FIELD_MASTER_HOSTNAME ).append( "= ?"); update.append( " WHERE " ); update.append( FIELD_CHANNEL_ID ).append( " = ? AND " ); update.append( FIELD_START_TIME ).append( " = ?" ); diff --git a/src/org/mythtv/db/dvr/ProgramDaoHelper.java b/src/org/mythtv/db/dvr/ProgramDaoHelper.java index 350698b7..9a1f3c90 100644 --- a/src/org/mythtv/db/dvr/ProgramDaoHelper.java +++ b/src/org/mythtv/db/dvr/ProgramDaoHelper.java @@ -153,7 +153,7 @@ protected int save( final Context context, final Uri uri, final LocationProfile if( null == context ) throw new RuntimeException( "ProgramDaoHelper is not initialized" ); - ContentValues values = convertProgramToContentValues( program ); + ContentValues values = convertProgramToContentValues( locationProfile, program ); String[] projection = new String[] { ProgramConstants._ID }; String selection = ProgramConstants.FIELD_CHANNEL_ID + " = ? AND " + ProgramConstants.FIELD_START_TIME + " = ?"; @@ -287,7 +287,7 @@ protected int load( final Context context, final Uri uri, final LocationProfile DateTime startTime = new DateTime( program.getStartTime() ); - ContentValues programValues = convertProgramToContentValues( program ); + ContentValues programValues = convertProgramToContentValues( locationProfile, program ); Cursor programCursor = context.getContentResolver().query( uri, programProjection, programSelection, new String[] { String.valueOf( program.getChannelInfo().getChannelId() ), String.valueOf( startTime.getMillis() ) }, null ); if( programCursor.moveToFirst() ) { //Log.v( TAG, "load : UPDATE PROGRAM channel=" + program.getChannelInfo().getChannelNumber() + ", startTime=" + DateUtils.dateTimeFormatterPretty.print( startTime ) + "(" + startTime + ")" ); @@ -326,12 +326,12 @@ protected int load( final Context context, final Uri uri, final LocationProfile if( !inError && null != program.getRecording() ) { String[] recordingProjection = new String[] { RecordingConstants.TABLE_NAME + "_" + RecordingConstants._ID }; - String recordingSelection = RecordingConstants.FIELD_RECORD_ID + " = ? AND " + RecordingConstants.FIELD_START_TIME + " = ? AND " + RecordingConstants.FIELD_HOSTNAME + " = ?"; + String recordingSelection = RecordingConstants.FIELD_RECORD_ID + " = ? AND " + RecordingConstants.FIELD_START_TIME + " = ? AND " + RecordingConstants.FIELD_MASTER_HOSTNAME + " = ?"; String[] recordingSelectionArgs = new String[] { String.valueOf( program.getRecording().getRecordId() ), String.valueOf( program.getStartTime().getMillis() ), locationProfile.getHostname() }; Log.v( TAG, "load : recording=" + program.getRecording().toString() ); - ContentValues recordingValues = mRecordingDaoHelper.convertRecordingToContentValues( context, locationProfile, program.getRecording(), program.getStartTime() ); + ContentValues recordingValues = mRecordingDaoHelper.convertRecordingToContentValues( locationProfile, program.getRecording(), program.getStartTime() ); Cursor recordingCursor = context.getContentResolver().query( RecordingConstants.CONTENT_URI, recordingProjection, recordingSelection, recordingSelectionArgs, null ); if( recordingCursor.moveToFirst() ) { Log.v( TAG, "load : UPDATE RECORDING program=" + program.getTitle() + ", recording=" + program.getRecording().getRecordId() ); @@ -413,7 +413,7 @@ protected int load( final Context context, final Uri uri, final LocationProfile ops.add( ContentProviderOperation.newDelete( RecordingConstants.CONTENT_URI ) - .withSelection( RecordingConstants.FIELD_RECORD_ID + " = ? AND " + RecordingConstants.FIELD_START_TIME + " = ? AND " + RecordingConstants.FIELD_HOSTNAME + " = ?", new String[] { String.valueOf( program.getRecording().getRecordId() ), String.valueOf( program.getStartTime().getMillis() ), locationProfile.getHostname() } ) + .withSelection( RecordingConstants.FIELD_RECORD_ID + " = ? AND " + RecordingConstants.FIELD_START_TIME + " = ? AND " + RecordingConstants.FIELD_MASTER_HOSTNAME + " = ?", new String[] { String.valueOf( program.getRecording().getRecordId() ), String.valueOf( program.getStartTime().getMillis() ), locationProfile.getHostname() } ) .withYieldAllowed( true ) .build() ); @@ -473,7 +473,7 @@ public Program convertCursorToProgram( Cursor cursor ) { // Long id = null; DateTime startTime = null, endTime = null, lastModified = null, airDate = null; - String title = "", subTitle = "", category = "", categoryType = "", seriesId = "", programId = "", fileSize = "", programFlags = "", hostname = "", filename = "", description = "", inetref = "", season = "", episode = ""; + String title = "", subTitle = "", category = "", categoryType = "", seriesId = "", programId = "", fileSize = "", programFlags = "", hostname = "", filename = "", description = "", inetref = "", season = "", episode = "", masterHostname = ""; int repeat = -1, videoProps = -1, audioProps = -1, subProps = -1; float stars = 0.0f; @@ -577,6 +577,10 @@ public Program convertCursorToProgram( Cursor cursor ) { episode = cursor.getString( cursor.getColumnIndex( ProgramConstants.FIELD_EPISODE ) ); } + if( cursor.getColumnIndex( ProgramConstants.FIELD_MASTER_HOSTNAME ) != -1 ) { + masterHostname = cursor.getString( cursor.getColumnIndex( ProgramConstants.FIELD_MASTER_HOSTNAME ) ); + } + if( cursor.getColumnIndex( ProgramConstants.FIELD_CHANNEL_ID ) != -1 ) { channelInfo = mChannelDaoHelper.convertCursorToChannelInfo( cursor ); } @@ -628,7 +632,7 @@ public Program convertCursorToProgram( Cursor cursor ) { return program; } - protected ContentValues[] convertProgramsToContentValuesArray( final List programs ) { + protected ContentValues[] convertProgramsToContentValuesArray( final LocationProfile locationProfile, final List programs ) { // Log.v( TAG, "convertProgramsToContentValuesArray : enter" ); if( null != programs && !programs.isEmpty() ) { @@ -638,7 +642,7 @@ protected ContentValues[] convertProgramsToContentValuesArray( final List