Example #1
0
def add_profile(profile):
	dblayer.run("INSERT INTO Profiles (type, datasource, localSource, "\
			"localSourceTitle, remoteAccountId, remoteSource, "\
			"remoteSourceTitle, enabled, direction, "\
			"lastUpdate, lastLocalUpdate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0)", \
			profile)
	dblayer.commit()
Example #2
0
def auto_sync_toggled(auto_button, time_button):
	active = auto_button.get_active()
	if active:
		(hours, minutes) = time_button.get_time()
		event = alarm.Event()
		event.appid = "erminig"
		event.title = "Synchronization with erminig"
		#event.flags |= alarm.EVENT_RUN_DELAYED
		action = event.add_actions(1)[0]
		action.flags |= alarm.ACTION_WHEN_TRIGGERED | alarm.ACTION_WHEN_DELAYED | alarm.ACTION_TYPE_EXEC
		action.command = os.path.abspath(sys.argv[0]) + " -a -d"
		recur = event.add_recurrences(1)[0]
		# let's see what this does...
		recur.mask_min = 1 << minutes
		recur.mask_hour = 1 << hours
		# initialize alarm time to somewhere in the future
		event.alarm_time = time.time() + 5
		# lt = time.localtime(time.time() + 5)
		# tz = time.tzname[lt.tm_isdst]
		# event.alarm_time = time.mktime(recur.next(lt, tz))
		event.recurrences_left = -1
		sync_id=alarm.add_event(event)
		auto_sync_update_syncid(sync_id)
		auto_sync_update_synctime(hours, minutes)
	else:
		alarm.delete_event(int(auto_sync_get_syncid()))
		dblayer.run("DELETE FROM Prefs where name='auto_sync_id'")
		dblayer.commit()
Example #3
0
def add_profile(profile):
    dblayer.run("INSERT INTO Profiles (type, datasource, localSource, "\
      "localSourceTitle, remoteAccountId, remoteSource, "\
      "remoteSourceTitle, enabled, direction, "\
      "lastUpdate, lastLocalUpdate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 0)", \
      profile)
    dblayer.commit()
Example #4
0
def auto_sync_toggled(auto_button, time_button):
    active = auto_button.get_active()
    if active:
        (hours, minutes) = time_button.get_time()
        event = alarm.Event()
        event.appid = "erminig"
        event.title = "Synchronization with erminig"
        #event.flags |= alarm.EVENT_RUN_DELAYED
        action = event.add_actions(1)[0]
        action.flags |= alarm.ACTION_WHEN_TRIGGERED | alarm.ACTION_WHEN_DELAYED | alarm.ACTION_TYPE_EXEC
        action.command = os.path.abspath(sys.argv[0]) + " -a -d"
        recur = event.add_recurrences(1)[0]
        # let's see what this does...
        recur.mask_min = 1 << minutes
        recur.mask_hour = 1 << hours
        # initialize alarm time to somewhere in the future
        event.alarm_time = time.time() + 5
        # lt = time.localtime(time.time() + 5)
        # tz = time.tzname[lt.tm_isdst]
        # event.alarm_time = time.mktime(recur.next(lt, tz))
        event.recurrences_left = -1
        sync_id = alarm.add_event(event)
        auto_sync_update_syncid(sync_id)
        auto_sync_update_synctime(hours, minutes)
    else:
        alarm.delete_event(int(auto_sync_get_syncid()))
        dblayer.run("DELETE FROM Prefs where name='auto_sync_id'")
        dblayer.commit()
Example #5
0
def auto_sync_update_syncid(sync_id):
    if auto_sync_get_syncid() is None:
        dblayer.run(
            "INSERT INTO Prefs (name, value) values ('auto_sync_id', '%d')" %
            sync_id)
    else:
        dblayer.run("UPDATE Prefs SET value='%d' where name='auto_sync_id'" %
                    sync_id)
    dblayer.commit()
Example #6
0
def auto_sync_update_synctime(sync_hour, sync_min):
    if auto_sync_get_synctime() is None:
        dblayer.run(
            "INSERT INTO Prefs (name, value) values ('auto_sync_time', '%d:%d')"
            % (sync_hour, sync_min))
    else:
        dblayer.run(
            "UPDATE Prefs SET value='%d:%d' where name='auto_sync_time'" %
            (sync_hour, sync_min))
    dblayer.commit()
Example #7
0
def insertNewGoogleEventLocally(event, cid, pid):
	global localEventsTouched

	lastId = cwrapper.addLocalCalendarEntry(cid, event)

	if lastId == None:
		logger.append("Error when inserting event locally")
		return

	dblayer.run("INSERT INTO Xrefs (pid, lid, gid) VALUES (?, ?, ?)", (pid, lastId, event.get_id()))
	dblayer.commit()
	localEventsTouched.append(lastId)
Example #8
0
def insertNewGoogleEventLocally(event, cid, pid):
    global localEventsTouched

    lastId = cwrapper.addLocalCalendarEntry(cid, event)

    if lastId == None:
        logger.append("Error when inserting event locally")
        return

    dblayer.run("INSERT INTO Xrefs (pid, lid, gid) VALUES (?, ?, ?)",
                (pid, lastId, event.get_id()))
    dblayer.commit()
    localEventsTouched.append(lastId)
Example #9
0
def removeCancelledEventLocally(cid, gid):
    # get local ID from googleId:
    lid = getLocalIdFromGoogleId(gid)
    if not lid:
        return

    logger.append("Removing local event (Deleted from Google -> %s)" % (gid))

    # purge Calendar entry:
    cwrapper.removeCancelledEventLocally(cid, lid)

    # purge entry in correspondance table:
    dblayer.run("DELETE FROM Xrefs WHERE lid=?", (lid, ))
    dblayer.commit()
Example #10
0
def removeCancelledEventLocally(cid, gid):
	# get local ID from googleId:
	lid = getLocalIdFromGoogleId(gid)
	if not lid:
		return

	logger.append("Removing local event (Deleted from Google -> %s)" % (gid))

	# purge Calendar entry:
	cwrapper.removeCancelledEventLocally(cid, lid)

	# purge entry in correspondance table:
	dblayer.run("DELETE FROM Xrefs WHERE lid=?", (lid, ))
	dblayer.commit()
Example #11
0
def update_profile(profile):
    dblayer.run("UPDATE Profiles SET type=?, datasource=?, localSource=?, "\
      "localSourceTitle=?, remoteAccountId=?, remoteSource=?, "\
      "remoteSourceTitle=?, enabled=?, direction=? WHERE "\
      "id=?", profile)
    dblayer.commit()
Example #12
0
def remove_by_id(id):
    dblayer.run("DELETE FROM Profiles WHERE id=?", (id, ))
    dblayer.run("DELETE FROM Xrefs WHERE pid=?", (id, ))
    dblayer.commit()
Example #13
0
	new_event = None
	try:
		new_event = google_api.run_google_action(google_api.gd_client.InsertEvent, event, urllib.quote('/calendar/feeds/' + googleid + '/private/full'))
	except ErminigGoogleError, e:
		error_win.display(e.title(), e.description())
		return

	if new_event == None:
		logger.append("Got a None event....skipping")
		return

	gid = (new_event.id.text.rpartition("/"))[2]
	# insert correspondance table entry:
	dblayer.run("INSERT INTO Xrefs (pid, lid, gid) VALUES (?, ?, ?)", \
			(pid, evt.get_id(), gid))
	dblayer.commit()

def getNewEventsFromLocal(pid, localSource, remoteSource, lastSync, progress):
	# Those are new events to create in Google:
	evts = queryNewLocalEvents(lastSync, localSource)
	if not evts:
		update_progress(progress, 1.0/3)
		return

	progress_inc = 1.0/3.0/len(evts)
	progress_val = 0.0
	for e in evts:
		progress_val = progress_val + progress_inc
		update_progress(progress, progress_val)

		event = Event(e[3], e[4], e[5], e[1], e[2], e[6], \
Example #14
0
def delete_account_by_id(id):
    dblayer.run("DELETE FROM GoogleAccounts WHERE id=?", (id, ))
    dblayer.run("DELETE FROM Profiles WHERE remoteAccountId=?", (id, ))
    dblayer.commit()
Example #15
0
def update_account(username, password, id):
    dblayer.run("UPDATE GoogleAccounts SET username=?, password=? WHERE "\
      "id=?", (username, password, id))
    dblayer.commit()
Example #16
0
def set_last_sync(pid, t, t2):
    dblayer.run("UPDATE Profiles SET lastUpdate=? WHERE id=?", (t, pid))
    dblayer.run("UPDATE Profiles SET lastLocalUpdate=? WHERE id=?", (t2, pid))
    dblayer.commit()
Example #17
0
def update_account(username, password, id):
	dblayer.run("UPDATE GoogleAccounts SET username=?, password=? WHERE "\
			"id=?", (username, password, id))
	dblayer.commit()
Example #18
0
def remove_by_id(id):
	dblayer.run("DELETE FROM Profiles WHERE id=?", (id,))
	dblayer.run("DELETE FROM Xrefs WHERE pid=?", (id,))
	dblayer.commit()
Example #19
0
def update_profile(profile):
	dblayer.run("UPDATE Profiles SET type=?, datasource=?, localSource=?, "\
			"localSourceTitle=?, remoteAccountId=?, remoteSource=?, "\
			"remoteSourceTitle=?, enabled=?, direction=? WHERE "\
			"id=?", profile)
	dblayer.commit()
Example #20
0
def auto_sync_update_synctime(sync_hour, sync_min):
	if auto_sync_get_synctime() is None:
		dblayer.run("INSERT INTO Prefs (name, value) values ('auto_sync_time', '%d:%d')" % (sync_hour,sync_min))
	else:
		dblayer.run("UPDATE Prefs SET value='%d:%d' where name='auto_sync_time'" % (sync_hour,sync_min))
	dblayer.commit()
Example #21
0
def auto_sync_update_syncid(sync_id):
	if auto_sync_get_syncid() is None:
		dblayer.run("INSERT INTO Prefs (name, value) values ('auto_sync_id', '%d')" % sync_id)
	else:
		dblayer.run("UPDATE Prefs SET value='%d' where name='auto_sync_id'" % sync_id)
	dblayer.commit()
Example #22
0
def set_last_sync(pid, t, t2):
	dblayer.run("UPDATE Profiles SET lastUpdate=? WHERE id=?", (t, pid))
	dblayer.run("UPDATE Profiles SET lastLocalUpdate=? WHERE id=?", (t2, pid))
	dblayer.commit()
Example #23
0
def register_new_account(username, password):
	dblayer.run("INSERT INTO GoogleAccounts (username, password) VALUES "\
			"(?, ?)", (username, password))
	dblayer.commit()
Example #24
0
def register_new_account(username, password):
    dblayer.run("INSERT INTO GoogleAccounts (username, password) VALUES "\
      "(?, ?)", (username, password))
    dblayer.commit()
Example #25
0
def delete_account_by_id(id):
	dblayer.run("DELETE FROM GoogleAccounts WHERE id=?", (id,))
	dblayer.run("DELETE FROM Profiles WHERE remoteAccountId=?", (id,))
	dblayer.commit()
Example #26
0
        new_event = google_api.run_google_action(
            google_api.gd_client.InsertEvent, event,
            urllib.quote('/calendar/feeds/' + googleid + '/private/full'))
    except ErminigGoogleError, e:
        error_win.display(e.title(), e.description())
        return

    if new_event == None:
        logger.append("Got a None event....skipping")
        return

    gid = (new_event.id.text.rpartition("/"))[2]
    # insert correspondance table entry:
    dblayer.run("INSERT INTO Xrefs (pid, lid, gid) VALUES (?, ?, ?)", \
      (pid, evt.get_id(), gid))
    dblayer.commit()


def getNewEventsFromLocal(pid, localSource, remoteSource, lastSync, progress):
    # Those are new events to create in Google:
    evts = queryNewLocalEvents(lastSync, localSource)
    if not evts:
        update_progress(progress, 1.0 / 3)
        return

    progress_inc = 1.0 / 3.0 / len(evts)
    progress_val = 0.0
    for e in evts:
        progress_val = progress_val + progress_inc
        update_progress(progress, progress_val)