Save DeviceItems to the sqlite database instead of the JSON one.

Rewrote DeviceItem to inherit from DDBObject rather than store itself on a
JSON database.

Updated code that upgrades from old JSON databases:
  - Kept the code that imports data into the metadata tables

  - Added code that creates an entry in device_item for JSON items

  - For each item that has an entry in the metadata_status table, but not
    device_item, create an entry in device_item using the data from
    metadata_status (this handles items that were created by miro 5.x)

  - Remove code that handled items where the upgrade code failed.  Now we'll
    just create new entries for any files found in scan_device_for_files()
    that don't have a corresponding DeviceItem entry.

Store a DBInfo object in our device database rather than just the sqlite
database.

Changed a lot of code in devices.py to work with the new DeviceItem object.

Made a base class for both Item and DeviceItem.  Moved a bunch of code from
Item into ItemBase.

Moved code that tests upgrading device items from the JSON data from
metadatatest to devicestest.  Now it tests creating DeviceItems in addition to
metadata objects.

A couple things are still not working yet:
  - We don't ever set the auto-sync flag
  - We need to replace the ItemSource code with a version of ItemTracker that
    works with devices
Added code to upgrade device databases from version 5.x.

This makes things a bit more complex because we need to worry about upgrading
from both 4.x versions and 5.x versions.  Changed the devicedatabaseupgrade
code from a function object to a regular class.  It needed to be changed to
deal with the extra complexity.

Made it so that database upgrade funcs conditionally run based on if the
database is the main DB or a device database.

Added unittests to check things.

Changed the linux setup.py to copy the entire testdata tree to the resources
directory.  This way we don't need to keep modifying it every time we add a
subdirectory.
Added test for our device database upgrades

This one uses basically the same code as the regular db upgrade test.  We
check that the schema is the same for a fresh database and one that was
upgraded.
Moved code that creates objects to a single module

I think this is a nice cleanup.  Now it can be used by any unit test.  I also
think it's better to have a separate module than to shove it in with the rest
of the stuff in framework.py
Refactored item/itemtrack to make them more flexible.

This is all preparation for making a version of ItemTracker that works with
device databases.  For those, we are using the device_item table instead of
the item table and also we aren't joining to the tables like
remote_downloader and icon_cache.

The steps to make ItemTracker work with a device database are:

- Subclass ItemSelectInfo and define the select for device databases
- Subclass ItemInfo and override the select_info attribute
- Subclass ItemTracker and override the item_info_class attribute
Added SignalEmitter.connect_after()

Used it to send the ItemChanges message.  This is also in preparation using
ItemChangeTracker for device databases.  This way we know when our callback is
called the main database and all device databases have committed their
transactions.
Added note for device upgrades
Implemented DeviceItemTracker.

Wrote DeviceItemInfo, which subclasess ItemInfo, but is created from a
different SQL query.

We now create a ConnectionPool object for each connected device on the
frontend.  There should only be a connection while the tab is being displayed,
so it shouldn't interfere with ejection.

We also create a subclass of ItemChangeTracker that handles changes for all
device items.

Fixed a couple bugs with the ConnectionPool._check_wal_mode() logic.
Changed DeviceItemInfo to make it work like ItemInfo
Reimplemented the DeviceSyncManager and added tests for it.

Added fetch_device_item_info() function.  I don't think I ended up using it,
but I think it's useful in any case.

Fixed auto_sync code.
Refactored the ItemTracker class hierarchy.

We were going to run into problems because the frontend subclasses
ItemTracker, but we were also subclassing it for DeviceItemTracker.  We could
solve that with a mixin classes, but that doesn't seem very clean to me.

Instead, made it so ItemTrackerQuery is the object that stores the which
ItemInfo/ItemSelectInfo classes we are going to use.  This makes sense, since
the ItemTrackerQuery is needs that info.

The result is that we can subclass ItemTracker with less pain in the frontend.

Moved the code that handles keeping a connection pool for each device into
connectionpool.py.  That doesn't need to be inside the ItemTracker class.
Changed item URL columns to use NULL instead of an empty string.

This matches how I implemented things in device_item, and I think it makes
more sense.
Started showing item lists for devices.

Added DeviceItemList class and used that to handle the data.

Created DeviceLiveStorage class that modifies LiveStorage slightly to not
create a full text search table.  In the future we should change this to make
one that uses device_item as its content source.

Fixed a bunch of bugs that showed up when I tried to use the device code with
a real database.
Made the ItemSource code work with the new item infos

Created version of ItemSource that works with the new ItemInfo system.  It
works like the old ItemSource class in that it tries to abstract away the
differences between regular databases and device databases.

Added an item_source attribute to ItemInfo and device_id to DeviceItemInfo.
Fixed DeviceItem so that we set device_id when we restore items.

Fixed ItemInfo.__str__ method.
Fixed the drag code for DeviceController

This still doesn't work with the drop code, but now at least it doesn't crash.
I'm not sure if things ever worked.
Fixed DeviceConnectionPoolMap to handle changed DeviceInfos

This handles the case where miro starts up and the device isn't mounted, then
the user mounts it.  In that case DeviceConnectionPoolMap first sees the
DeviceInfo when it's part of the added list, but at that point db_info=None.
When it sees it's part of the changed list and db_info is no longer None, then
it should create a connection pool.
Merge pull request #410 from pculture/devicedata

Devicedata