Ejemplo n.º 1
0
def change_synchronization(account_settings):
    log_debug('Changing synchronization for account: %s' % (account_settings.account_name))
    account_settings.synchronisation = False
    sync_settings_valid = False
    #Enable synchronization?
    dialog = xbmcgui.Dialog()
    if dialog.yesno(ADDON_NAME, LANGUAGE_STRING(30101), account_settings.account_name + '?' ) == True:
         account_settings.synchronisation = True
    log_debug('Synchronization enabled: %s' % (account_settings.synchronisation) )
    if account_settings.synchronisation:
        #select the local folder
        dialog = xbmcgui.Dialog()
        # 3= ShowAndGetWriteableDirectory, 
        selected_folder = dialog.browse(3, LANGUAGE_STRING(30102), 'files', mask='', treatAsFolder=True, defaultt=account_settings.syncpath)
        selected_folder = selected_folder.decode("utf-8")
        log_debug('Selected local folder: %s' % (selected_folder) )
        if selected_folder != u'':
            account_settings.syncpath = selected_folder
            from resources.lib.dropboxfilebrowser import DropboxFileBrowser
            #select the remote folder
            dialog = DropboxFileBrowser("FileBrowser.xml", ADDON_PATH)
            client = XBMCDropBoxClient(access_token=account_settings.access_token)
            dialog.setDBClient(client)
            dialog.setHeading(LANGUAGE_STRING(30109), account_settings.remotepath)
            dialog.doModal()
            log_debug('Selected remote folder: %s' % (dialog.selectedFolder) )
            if dialog.selectedFolder:
                account_settings.remotepath = dialog.selectedFolder
                #set synchronization frequency
                dialog = xbmcgui.Dialog()
                valid_freq = False
                while not valid_freq:
                    #0 = ShowAndGetNumber
                    freq_str = dialog.numeric(0, LANGUAGE_STRING(30105), str(account_settings.syncfreq) )
                    try:
                        #check for a vaild freq
                        freq = int(freq_str)
                    except ValueError:
                        freq = -1
                    if 5 <= freq <= 1440:
                        account_settings.syncfreq = freq
                        log_debug('Synchronization frequency set: %s' % (freq))
                        valid_freq = True
                    else:
                        log_debug('Wrong frequency value')
                        #Wrong timeout
                        dialog = xbmcgui.Dialog()
                        dialog.ok(ADDON_NAME, LANGUAGE_STRING(30208))
                #done
                sync_settings_valid = True
    else:
        sync_settings_valid = True
    if sync_settings_valid:
        account_settings.save()
        #Notify the DropboxSynchronizer
        NotifySyncClient().account_settings_changed(account_settings)
def change_synchronization(account_settings):
    log_debug('Changing synchronization for account: %s' % (account_settings.account_name))
    account_settings.synchronisation = False
    sync_settings_valid = False
    #Enable synchronization?
    dialog = xbmcgui.Dialog()
    if dialog.yesno(ADDON_NAME, LANGUAGE_STRING(30101), account_settings.account_name + '?' ) == True:
         account_settings.synchronisation = True
    log_debug('Synchronization enabled: %s' % (account_settings.synchronisation) )
    if account_settings.synchronisation:
        #select the local folder
        dialog = xbmcgui.Dialog()
        # 3= ShowAndGetWriteableDirectory, 
        selected_folder = dialog.browse(3, LANGUAGE_STRING(30102), 'files', mask='', treatAsFolder=True, defaultt=account_settings.syncpath)
        selected_folder = selected_folder.decode("utf-8")
        log_debug('Selected local folder: %s' % (selected_folder) )
        if selected_folder != u'':
            account_settings.syncpath = selected_folder
            from resources.lib.dropboxfilebrowser import DropboxFileBrowser
            #select the remote folder
            dialog = DropboxFileBrowser("FileBrowser.xml", ADDON_PATH)
            client = XBMCDropBoxClient(access_token=account_settings.access_token)
            dialog.setDBClient(client)
            dialog.setHeading(LANGUAGE_STRING(30109), account_settings.remotepath)
            dialog.doModal()
            log_debug('Selected remote folder: %s' % (dialog.selectedFolder) )
            if dialog.selectedFolder:
                account_settings.remotepath = dialog.selectedFolder
                #set synchronization frequency
                dialog = xbmcgui.Dialog()
                valid_freq = False
                while not valid_freq:
                    #0 = ShowAndGetNumber
                    freq_str = dialog.numeric(0, LANGUAGE_STRING(30105), str(account_settings.syncfreq) )
                    try:
                        #check for a vaild freq
                        freq = int(freq_str)
                    except ValueError:
                        freq = -1
                    if 5 <= freq <= 1440:
                        account_settings.syncfreq = freq
                        log_debug('Synchronization frequency set: %s' % (freq))
                        valid_freq = True
                    else:
                        log_debug('Wrong frequency value')
                        #Wrong timeout
                        dialog = xbmcgui.Dialog()
                        dialog.ok(ADDON_NAME, LANGUAGE_STRING(30208))
                #done
                sync_settings_valid = True
    else:
        sync_settings_valid = True
    if sync_settings_valid:
        account_settings.save()
        #Notify the DropboxSynchronizer
        NotifySyncClient().account_settings_changed(account_settings)
Ejemplo n.º 3
0
Archivo: addon.py Proyecto: noba3/KoTos
         dialog = xbmcgui.Dialog()
         if dialog.yesno(ADDON_NAME, LANGUAGE_STRING(30023), path ) == True:
             success = client.delete(path)
             if success:
                 log('File removed: %s' % path)
                 NotifySyncClient().sync_path(account_settings, path)
             else:
                 log_error('File removed Failed: %s' % path)
             xbmc.executebuiltin('container.Refresh()')
 elif action == 'copy':
     if 'path' in params:
         path = urllib.unquote( params['path'] ).decode("utf-8")
         dialog = DropboxFileBrowser("FileBrowser.xml", ADDON_PATH)
         dialog.setDBClient(client)
         dialog.setHeading(LANGUAGE_STRING(30025) + LANGUAGE_STRING(30026))
         dialog.doModal()
         if dialog.selectedFolder:
             #dropbox path -> don't use os.path.join()!
             toPath = dialog.selectedFolder
             if dialog.selectedFolder[-1:] != DROPBOX_SEP: toPath += DROPBOX_SEP
             toPath += os.path.basename(path)
             success = client.copy(path, toPath)
             if success:
                 log('File copied: %s to %s' % (path, toPath) ) 
                 NotifySyncClient().sync_path(account_settings, toPath)
             else:
                 log_error('File copy Failed: %s to %s' % (path, toPath) )
         del dialog
 elif action == 'move':
     if 'path' in params:
         path = urllib.unquote( params['path'] ).decode("utf-8")