// Path: src/com/deliciousdroid/Constants.java
// public class Constants {
// 
//     /**
//      * Account type string.
//      */
//     public static final String ACCOUNT_TYPE = "com.deliciousdroid";
//     
//     public static final Uri CONTENT_URI_BASE = Uri.parse("content://com.deliciousdroid");
//     
//     public static final String CONTENT_SCHEME = "content";
//     
//     public static final String EXTRA_DESCRIPTION = "com.deliciousdroid.bookmark.description";
//     public static final String EXTRA_NOTES = "com.deliciousdroid.bookmark.notes";
//     public static final String EXTRA_TAGS = "com.deliciousdroid.bookmark.tags";
//     public static final String EXTRA_PRIVATE = "com.deliciousdroid.bookmark.private";
//     public static final String EXTRA_ERROR = "com.deliciousdroid.bookmark.error";
//     public static final String EXTRA_TIME = "com.deliciousdroid.bookmark.time";
// 	public static final String EXTRA_UPDATE = "com.deliciousdroid.bookmark.update";
// 	
// 	public static final String TEXT_EXTRACTOR_URL = "http://viewtext.org/api/text?url=";
// 	
// 	public static final String SYNC_MARKER_KEY = "com.deliciousdroid.BookmarkSyncAdapter.marker";
// 	
// 	public static final int BOOKMARK_PAGE_SIZE = 500;
// 	
// 	public static final String ACTION_SEARCH_SUGGESTION = "com.deliciousdroid.intent.action.SearchSuggestion";
// 	
// 	public static final String SUGGEST_COLUMN_TEXT_2_URL = "suggest_text_2_url";
// 
//     /**
//      * Authtoken type string.
//      */
//     public static final String AUTHTOKEN_TYPE = "com.deliciousdroid";
//     
//     public static final String AUTH_PREFS_NAME = "com.deliciousdroid.auth";
//     
//     public static final String PREFS_AUTH_TYPE = "authentication_type";
//     public static final String AUTH_TYPE_DELICIOUS = "delicious";
//     
//     public static final String GPL_URL = "http://www.gnu.org/licenses/gpl-3.0.txt";
//     public static final String MANUAL_URL = "http://code.google.com/p/deliciousdroid/wiki/Manual";
//     public static final String DONATION_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6ERJRC6SWL9ZC";
//     
//     public static enum BookmarkViewType {VIEW, READ, WEB};
// }
// 
// Path: src/com/deliciousdroid/syncadapter/PeriodicSyncReceiver.java
// public final class PeriodicSyncReceiver extends BroadcastReceiver {
// 
// 	private static final String KEY_AUTHORITY = "authority";
// 
// 	private static final String KEY_USERDATA = "userdata";
// 
// 	public static Intent createIntent(Context context, String authority, Bundle extras) {
// 		Intent intent = new Intent(context, PeriodicSyncReceiver.class);
// 		intent.putExtra(KEY_AUTHORITY, authority);
// 		intent.putExtra(KEY_USERDATA, extras);
// 		return intent;
// 	}
// 
// 	public static PendingIntent createPendingIntent(Context context, String authority, Bundle extras) {
// 		int requestCode = 0;
// 		Intent intent = createIntent(context, authority, extras);
// 		int flags = 0;
// 		return PendingIntent.getBroadcast(context, requestCode, intent, flags);
// 	}
// 
// 	@Override
// 	public void onReceive(Context context, Intent intent) {
// 		String authority = intent.getStringExtra(KEY_AUTHORITY);
// 		Bundle extras = intent.getBundleExtra(KEY_USERDATA);
// 
// 		ContentResolver.requestSync(null, authority, extras);
// 	}
// }


import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
import com.deliciousdroid.Constants;
import com.deliciousdroid.syncadapter.PeriodicSyncReceiver;
import android.annotation.TargetApi;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.ContentResolver;
/*
 * DeliciousDroid - http://code.google.com/p/DeliciousDroid/
 *
 * Copyright (C) 2010 Matt Schmidt
 *
 * DeliciousDroid is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 3 of the License,
 * or (at your option) any later version.
 *
 * DeliciousDroid is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with DeliciousDroid; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

package com.deliciousdroid.util;



public class SyncUtils {

	@TargetApi(8)
	public static void addPeriodicSync(String authority, Bundle extras, long frequency, Context context) {
		long pollFrequencyMsec = frequency * 60000;
		
		if(android.os.Build.VERSION.SDK_INT < 8) {
			AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
	
			int type = AlarmManager.ELAPSED_REALTIME_WAKEUP;
			long triggerAtTime = SystemClock.elapsedRealtime() + pollFrequencyMsec;
			long interval = pollFrequencyMsec;
// Path: src/com/deliciousdroid/Constants.java
// public class Constants {
// 
//     /**
//      * Account type string.
//      */
//     public static final String ACCOUNT_TYPE = "com.deliciousdroid";
//     
//     public static final Uri CONTENT_URI_BASE = Uri.parse("content://com.deliciousdroid");
//     
//     public static final String CONTENT_SCHEME = "content";
//     
//     public static final String EXTRA_DESCRIPTION = "com.deliciousdroid.bookmark.description";
//     public static final String EXTRA_NOTES = "com.deliciousdroid.bookmark.notes";
//     public static final String EXTRA_TAGS = "com.deliciousdroid.bookmark.tags";
//     public static final String EXTRA_PRIVATE = "com.deliciousdroid.bookmark.private";
//     public static final String EXTRA_ERROR = "com.deliciousdroid.bookmark.error";
//     public static final String EXTRA_TIME = "com.deliciousdroid.bookmark.time";
// 	public static final String EXTRA_UPDATE = "com.deliciousdroid.bookmark.update";
// 	
// 	public static final String TEXT_EXTRACTOR_URL = "http://viewtext.org/api/text?url=";
// 	
// 	public static final String SYNC_MARKER_KEY = "com.deliciousdroid.BookmarkSyncAdapter.marker";
// 	
// 	public static final int BOOKMARK_PAGE_SIZE = 500;
// 	
// 	public static final String ACTION_SEARCH_SUGGESTION = "com.deliciousdroid.intent.action.SearchSuggestion";
// 	
// 	public static final String SUGGEST_COLUMN_TEXT_2_URL = "suggest_text_2_url";
// 
//     /**
//      * Authtoken type string.
//      */
//     public static final String AUTHTOKEN_TYPE = "com.deliciousdroid";
//     
//     public static final String AUTH_PREFS_NAME = "com.deliciousdroid.auth";
//     
//     public static final String PREFS_AUTH_TYPE = "authentication_type";
//     public static final String AUTH_TYPE_DELICIOUS = "delicious";
//     
//     public static final String GPL_URL = "http://www.gnu.org/licenses/gpl-3.0.txt";
//     public static final String MANUAL_URL = "http://code.google.com/p/deliciousdroid/wiki/Manual";
//     public static final String DONATION_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6ERJRC6SWL9ZC";
//     
//     public static enum BookmarkViewType {VIEW, READ, WEB};
// }
// 
// Path: src/com/deliciousdroid/syncadapter/PeriodicSyncReceiver.java
// public final class PeriodicSyncReceiver extends BroadcastReceiver {
// 
// 	private static final String KEY_AUTHORITY = "authority";
// 
// 	private static final String KEY_USERDATA = "userdata";
// 
// 	public static Intent createIntent(Context context, String authority, Bundle extras) {
// 		Intent intent = new Intent(context, PeriodicSyncReceiver.class);
// 		intent.putExtra(KEY_AUTHORITY, authority);
// 		intent.putExtra(KEY_USERDATA, extras);
// 		return intent;
// 	}
// 
// 	public static PendingIntent createPendingIntent(Context context, String authority, Bundle extras) {
// 		int requestCode = 0;
// 		Intent intent = createIntent(context, authority, extras);
// 		int flags = 0;
// 		return PendingIntent.getBroadcast(context, requestCode, intent, flags);
// 	}
// 
// 	@Override
// 	public void onReceive(Context context, Intent intent) {
// 		String authority = intent.getStringExtra(KEY_AUTHORITY);
// 		Bundle extras = intent.getBundleExtra(KEY_USERDATA);
// 
// 		ContentResolver.requestSync(null, authority, extras);
// 	}
// }


// Path: src/com/deliciousdroid/util/SyncUtils.java
import android.content.Context;
import android.os.Bundle;
import android.os.SystemClock;
import com.deliciousdroid.Constants;
import com.deliciousdroid.syncadapter.PeriodicSyncReceiver;
import android.annotation.TargetApi;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.ContentResolver;

/*
 * DeliciousDroid - http://code.google.com/p/DeliciousDroid/
 *
 * Copyright (C) 2010 Matt Schmidt
 *
 * DeliciousDroid is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 3 of the License,
 * or (at your option) any later version.
 *
 * DeliciousDroid is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with DeliciousDroid; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

package com.deliciousdroid.util;



public class SyncUtils {

	@TargetApi(8)
	public static void addPeriodicSync(String authority, Bundle extras, long frequency, Context context) {
		long pollFrequencyMsec = frequency * 60000;
		
		if(android.os.Build.VERSION.SDK_INT < 8) {
			AlarmManager manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
	
			int type = AlarmManager.ELAPSED_REALTIME_WAKEUP;
			long triggerAtTime = SystemClock.elapsedRealtime() + pollFrequencyMsec;
			long interval = pollFrequencyMsec;
			PendingIntent operation = PeriodicSyncReceiver.createPendingIntent(context, authority, extras);