// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/Server.java
// public class Server {
//     public final String ip;
//     public String displayName;
//     private final Integer sshPort;
//     public final Integer vlcPort;
//     private String password;
//     private String lastPath;
// 
//     public Server(String ip, Integer vlcPort, Integer sshPort) {
//         this.ip = ip;
//         this.vlcPort = vlcPort;
//         this.sshPort = sshPort;
//         this.password = "";
//         this.displayName = null;
//     }
// 
//     public void setDisplayName(final String name) {
//         this.displayName = name;
//     }
// 
//     public String getDisplayName() {
//         return displayName;
//     }
// 
//     public String getFullDisplayName() {
//         if (displayName != null) {
//             return displayName + " (" + ip + ")";
//         } else {
//             return ip + ":" + vlcPort;
//         }
//     }
// 
//     public void setPassword(final String password) {
//         this.password = password;
//     }
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setLastPath(String lastPath) { this.lastPath = lastPath; }
//     public String getLastPath() { return this.lastPath; }
// }


import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.nicolasbrailo.vlcfreemote.model.Server;
import java.util.ArrayList;
import java.util.List;
                        COLUMN_VLCPORT + " INTEGER, " +
                        COLUMN_DISPLAY_NAME + " TEXT, " +
                        COLUMN_PASS + " TEXT, " +
                        COLUMN_LAST_USED + " INTEGER, " +
                        COLUMN_LAST_PATH + " TEXT, " +
                        "PRIMARY KEY ("+ COLUMN_IP + "," + COLUMN_VLCPORT + ") " +
               " )";
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if (newVersion == 2 &&  oldVersion == 1) {
            db.execSQL("ALTER TABLE " + TABLE_NAME +
                       " ADD COLUMN " + COLUMN_DISPLAY_NAME + " TEXT");
        } else {
            Log.e("ServerLocalSettings", "Invalid DB upgrade path. " +
                  "New version is " + newVersion + ", old is " + oldVersion);
        }
    }

    @Override
    protected String getDeleteTableSQL() {
        return "DROP TABLE IF EXISTS " + TABLE_NAME;
    }


    /**
     * Remember a server and its settings. Will automatically set the last used flag.
     * @param srv Last used server
     */
// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/model/Server.java
// public class Server {
//     public final String ip;
//     public String displayName;
//     private final Integer sshPort;
//     public final Integer vlcPort;
//     private String password;
//     private String lastPath;
// 
//     public Server(String ip, Integer vlcPort, Integer sshPort) {
//         this.ip = ip;
//         this.vlcPort = vlcPort;
//         this.sshPort = sshPort;
//         this.password = "";
//         this.displayName = null;
//     }
// 
//     public void setDisplayName(final String name) {
//         this.displayName = name;
//     }
// 
//     public String getDisplayName() {
//         return displayName;
//     }
// 
//     public String getFullDisplayName() {
//         if (displayName != null) {
//             return displayName + " (" + ip + ")";
//         } else {
//             return ip + ":" + vlcPort;
//         }
//     }
// 
//     public void setPassword(final String password) {
//         this.password = password;
//     }
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setLastPath(String lastPath) { this.lastPath = lastPath; }
//     public String getLastPath() { return this.lastPath; }
// }


// Path: app/src/main/java/com/nicolasbrailo/vlcfreemote/local_settings/RememberedServers.java
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.nicolasbrailo.vlcfreemote.model.Server;
import java.util.ArrayList;
import java.util.List;

                        COLUMN_VLCPORT + " INTEGER, " +
                        COLUMN_DISPLAY_NAME + " TEXT, " +
                        COLUMN_PASS + " TEXT, " +
                        COLUMN_LAST_USED + " INTEGER, " +
                        COLUMN_LAST_PATH + " TEXT, " +
                        "PRIMARY KEY ("+ COLUMN_IP + "," + COLUMN_VLCPORT + ") " +
               " )";
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if (newVersion == 2 &&  oldVersion == 1) {
            db.execSQL("ALTER TABLE " + TABLE_NAME +
                       " ADD COLUMN " + COLUMN_DISPLAY_NAME + " TEXT");
        } else {
            Log.e("ServerLocalSettings", "Invalid DB upgrade path. " +
                  "New version is " + newVersion + ", old is " + oldVersion);
        }
    }

    @Override
    protected String getDeleteTableSQL() {
        return "DROP TABLE IF EXISTS " + TABLE_NAME;
    }


    /**
     * Remember a server and its settings. Will automatically set the last used flag.
     * @param srv Last used server
     */
    public void rememberServer(final Server srv) {