1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 package org.mozilla.gecko.db; 6 7 import java.util.ArrayList; 8 9 import android.os.Parcel; 10 import android.os.Parcelable; 11 12 /** 13 * A thin representation of a remote client. 14 * <p> 15 * We use the hash of the client's GUID as the ID elsewhere. 16 */ 17 public class RemoteClient implements Parcelable { 18 public final String guid; 19 public final String name; 20 public final long lastModified; 21 public final String deviceType; 22 public final ArrayList<RemoteTab> tabs; 23 RemoteClient(String guid, String name, long lastModified, String deviceType)24 public RemoteClient(String guid, String name, long lastModified, String deviceType) { 25 this.guid = guid; 26 this.name = name; 27 this.lastModified = lastModified; 28 this.deviceType = deviceType; 29 this.tabs = new ArrayList<>(); 30 } 31 32 @Override describeContents()33 public int describeContents() { 34 return 0; 35 } 36 37 @Override writeToParcel(Parcel parcel, int flags)38 public void writeToParcel(Parcel parcel, int flags) { 39 parcel.writeString(guid); 40 parcel.writeString(name); 41 parcel.writeLong(lastModified); 42 parcel.writeString(deviceType); 43 parcel.writeTypedList(tabs); 44 } 45 46 public static final Creator<RemoteClient> CREATOR = new Creator<RemoteClient>() { 47 @Override 48 public RemoteClient createFromParcel(final Parcel source) { 49 final String guid = source.readString(); 50 final String name = source.readString(); 51 final long lastModified = source.readLong(); 52 final String deviceType = source.readString(); 53 54 final RemoteClient client = new RemoteClient(guid, name, lastModified, deviceType); 55 source.readTypedList(client.tabs, RemoteTab.CREATOR); 56 57 return client; 58 } 59 60 @Override 61 public RemoteClient[] newArray(final int size) { 62 return new RemoteClient[size]; 63 } 64 }; 65 isDesktop()66 public boolean isDesktop() { 67 return "desktop".equals(deviceType); 68 } 69 } 70