CREATE TABLE IF NOT EXISTS `app_intent` (
	`id`       INTEGER PRIMARY KEY AUTOINCREMENT,
	`action`   VARCHAR(38) NOT NULL,
	`message`  VARCHAR(20) NOT NULL,
	`type`     VARCHAR(50) NOT NULL,
	`label`    VARCHAR(50) NOT NULL,
	`labelStr` VARCHAR(50) NOT NULL,
	`icon`     TEXT,
	`sort_key` INTEGER,
	UNIQUE (`type`, `sort_key`),
	FOREIGN KEY (`action`) REFERENCES apps(`uid`) ON UPDATE CASCADE ON DELETE CASCADE
);

-- Intents
-- image/*
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('app_gallery', 'collect', 'image/*', 'Save to Gallery', 'intent.gallery.label', 'chrome://livemargins/skin/images/icons/gallery.png', 0);
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('{dcb0d1b8-7a02-41c3-9fc8-46b2405480b9}', 'edit', 'image/*', 'Edit using XiuXiu', 'intent.xiuxiu.label', 'chrome://livemargins/skin/images/icons/xiuxiu.ico', 1);
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('{72600762-7580-43d7-a991-7d05c3eed5ed}', 'note', 'image/*', 'Save to Maiku', 'intent.maiku.label', 'chrome://livemargins/skin/images/icons/maiku.png', 2);
-- text/*
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('app_search', 'search', 'text/*', 'Search using MultiSearch', 'intent.multi_search.label', 'chrome://livemargins/skin/images/icons/search.png', 0);
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('{a09cf36d-abbc-48ed-b0cc-77c650eb164e}', 'translate', 'text/*', 'Translate using Youdao', 'intent.youdao.label', 'chrome://livemargins/skin/images/icons/youdao.gif', 1);
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('{72600762-7580-43d7-a991-7d05c3eed5ed}', 'note', 'text/*', 'Save to Maiku', 'intent.maiku.label', 'chrome://livemargins/skin/images/icons/maiku.png', 2);
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('{6e881146-62e9-461d-884a-3e2caf10b0ab}', 'search', 'text/*', 'Search using Hudong', 'intent.hudong.label', 'chrome://livemargins/skin/images/icons/hudong.png', 3);
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('$app-search-engine$', 'search', 'text/*', 'Search using current engine', 'intent.searchengine.label', '', 4);
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('$app-share-tool$', 'share', 'text/*', 'Share selection', 'intent.share.label', '', 5);
-- text/html
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('{72600762-7580-43d7-a991-7d05c3eed5ed}', 'note', 'text/html', 'Save to Maiku', 'intent.maiku.label', 'chrome://livemargins/skin/images/icons/maiku.png', 0);
-- application/link
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('{72600762-7580-43d7-a991-7d05c3eed5ed}', 'note', 'application/link', 'Save to Maiku', 'intent.maiku.label', 'chrome://livemargins/skin/images/icons/maiku.png', 0);
INSERT INTO `app_intent`
	(`action`, `message`, `type`, `label` , `labelStr`, `icon`, `sort_key`)
VALUES
	('$app-share-tool$', 'share', 'application/link', 'Share selection', 'intent.share.label', '', 1);

-- Should be the same as 'extensions.livemargins@mozillaonline.com.sqlversion'
INSERT OR REPLACE INTO `metadata` (`key`, `value`) VALUES ('version', 4);