Search in sources :

Example 1 with Auth

use of org.storymaker.app.model.Auth in project storymaker by StoryMaker.

the class ArchiveUploader method start.

// FIXME move the render file checks into base class
@Override
public void start() {
    final SiteController controller = SiteController.getSiteController(ArchiveSiteController.SITE_KEY, mContext, mHandler, "" + mJob.getId());
    final Project project = mJob.getProject();
    final PublishJob publishJob = mJob.getPublishJob();
    final String path = publishJob.getLastRenderFilePath();
    final Auth auth = (new AuthTable()).getAuthDefault(mContext, ArchiveSiteController.SITE_KEY);
    if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
        jobProgress(mJob, 0, mContext.getString(R.string.uploading_to_internet_archive));
        HashMap<String, String> valueMap = publishJob.getMetadata();
        addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
        // FIXME need to hookup Account to this
        controller.upload(auth.convertToAccountObject(), valueMap);
    } else {
        Timber.d("Can't upload to Internet Archive server, last rendered file doesn't exist.");
        // TODO get this error back to the activity for display 
        // FIXME move to strings.xml
        jobFailed(null, ERROR_NO_RENDER_FILE, "Can't upload to Internet Archive server, last rendered file doesn't exist.");
    }
}
Also used : Project(org.storymaker.app.model.Project) Auth(org.storymaker.app.model.Auth) AuthTable(org.storymaker.app.model.AuthTable) SiteController(io.scal.secureshare.controller.SiteController) ArchiveSiteController(io.scal.secureshare.controller.ArchiveSiteController) File(java.io.File) PublishJob(org.storymaker.app.model.PublishJob)

Example 2 with Auth

use of org.storymaker.app.model.Auth in project storymaker by StoryMaker.

the class FacebookUploader method start.

// FIXME move the render file checks into base class
@Override
public void start() {
    // TODO Auto-generated constructor stub
    final SiteController controller = SiteController.getSiteController(FacebookSiteController.SITE_KEY, mContext, mHandler, "" + mJob.getId());
    final Project project = mJob.getProject();
    final PublishJob publishJob = mJob.getPublishJob();
    final String path = publishJob.getLastRenderFilePath();
    final Auth auth = (new AuthTable()).getAuthDefault(mContext, FacebookSiteController.SITE_KEY);
    if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
        Handler mainHandler = new Handler(mContext.getMainLooper());
        Runnable myRunnable = new Runnable() {

            // facebook seems to freak out if our service's looper is dead when it tries to send message back 
            @Override
            public void run() {
                jobProgress(mJob, 0, mContext.getString(R.string.uploading_to_facebook));
                HashMap<String, String> valueMap = publishJob.getMetadata();
                // need to extract raw photos
                // what happened to STORY_TYPE_PHOTO?
                // TODO: currently checking preferences, will revisit when ui is updated
                SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mContext);
                boolean uploadPhotos = sharedPref.getBoolean("pphotoformat", false);
                if ((publishJob.getProject().getStoryType() == Project.STORY_TYPE_ESSAY) && uploadPhotos) {
                    ArrayList<Media> photos = publishJob.getProject().getMediaAsList();
                    String photoString = "";
                    for (Media photo : photos) {
                        photoString = photoString + photo.getPath() + ";";
                    }
                    // drop trailing ;
                    photoString = photoString.substring(0, photoString.length() - 1);
                    valueMap.put(FacebookSiteController.PHOTO_SET_KEY, photoString);
                }
                addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
                controller.upload(auth.convertToAccountObject(), valueMap);
            }
        };
        mainHandler.post(myRunnable);
    } else {
        Timber.d("Can't upload to facebook, last rendered file doesn't exist.");
        // TODO get this error back to the activity for display 
        // FIXME move to strings.xml
        jobFailed(null, ERROR_NO_RENDER_FILE, "Can't upload to facebook, last rendered file doesn't exist.");
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) AuthTable(org.storymaker.app.model.AuthTable) Media(org.storymaker.app.model.Media) Handler(android.os.Handler) SiteController(io.scal.secureshare.controller.SiteController) FacebookSiteController(io.scal.secureshare.controller.FacebookSiteController) PublishJob(org.storymaker.app.model.PublishJob) Project(org.storymaker.app.model.Project) Auth(org.storymaker.app.model.Auth) File(java.io.File)

Example 3 with Auth

use of org.storymaker.app.model.Auth in project storymaker by StoryMaker.

the class SoundCloudUploader method start.

// FIXME move the render file checks into base class
@Override
public void start() {
    // TODO Auto-generated constructor stub
    final SiteController controller = SiteController.getSiteController(SoundCloudSiteController.SITE_KEY, mContext, mHandler, "" + mJob.getId());
    final Project project = mJob.getProject();
    final PublishJob publishJob = mJob.getPublishJob();
    final String path = publishJob.getLastRenderFilePath();
    final Auth auth = (new AuthTable()).getAuthDefault(mContext, SoundCloudSiteController.SITE_KEY);
    // FIXME deal with lack of auth credentials here
    if (Utils.stringNotBlank(path) && (new File(path)).exists()) {
        Handler mainHandler = new Handler(mContext.getMainLooper());
        Runnable myRunnable = new Runnable() {

            // facebook seems to freak out if our service's looper is dead when it tries to send message back 
            @Override
            public void run() {
                jobProgress(mJob, 0, mContext.getString(R.string.uploading_to_soundcloud));
                HashMap<String, String> valueMap = publishJob.getMetadata();
                addValuesToHashmap(valueMap, project.getTitle(), project.getDescription(), path);
                controller.upload(auth.convertToAccountObject(), valueMap);
            }
        };
        mainHandler.post(myRunnable);
    } else {
        Timber.d("Can't upload to SoundCloud, last rendered file doesn't exist.");
        // TODO get this error back to the activity for display 
        // FIXME move to strings.xml
        jobFailed(null, ERROR_NO_RENDER_FILE, "Can't upload to SoundCloud, last rendered file doesn't exist.");
    }
}
Also used : Project(org.storymaker.app.model.Project) Auth(org.storymaker.app.model.Auth) AuthTable(org.storymaker.app.model.AuthTable) Handler(android.os.Handler) SiteController(io.scal.secureshare.controller.SiteController) SoundCloudSiteController(io.scal.secureshare.controller.SoundCloudSiteController) File(java.io.File) PublishJob(org.storymaker.app.model.PublishJob)

Example 4 with Auth

use of org.storymaker.app.model.Auth in project storymaker by StoryMaker.

the class LoginActivity method saveCreds.

private void saveCreds(String user, String pass) {
    ArrayList<Auth> results = (new AuthTable()).getAuthsAsList(getApplicationContext(), Auth.SITE_STORYMAKER);
    for (Auth deleteAuth : results) {
        // only a single username/password is stored at a time
        deleteAuth.delete();
    }
    Auth storymakerAuth = new Auth(getApplicationContext(), "StoryMaker.cc", Auth.SITE_STORYMAKER, user, pass, null, null, new Date());
    storymakerAuth.save();
}
Also used : AuthTable(org.storymaker.app.model.AuthTable) Auth(org.storymaker.app.model.Auth) Date(java.util.Date)

Example 5 with Auth

use of org.storymaker.app.model.Auth in project storymaker by StoryMaker.

the class AccountsActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getIntent().getBooleanExtra("isDialog", false)) {
        setTheme(android.R.style.Theme_Holo_Light_Dialog_NoActionBar_MinWidth);
    }
    setContentView(R.layout.activity_accounts);
    boolean isUserLoggedIntoSM = false;
    Auth storymakerAuth = (new AuthTable()).getAuthDefault(getApplicationContext(), Auth.SITE_STORYMAKER);
    if (storymakerAuth != null) {
        // FIXME we should check a little more carefully if the auth credentials are valid
        isUserLoggedIntoSM = true;
    }
    Bundle bundle = null;
    Intent intent = getIntent();
    bundle = new Bundle();
    bundle.putBoolean("isDialog", intent.getBooleanExtra("isDialog", false));
    bundle.putBoolean("inSelectionMode", intent.getBooleanExtra("inSelectionMode", false));
    bundle.putBoolean("isUserLoggedIntoSM", isUserLoggedIntoSM);
    addChooseAccountFragment(bundle);
}
Also used : Bundle(android.os.Bundle) Auth(org.storymaker.app.model.Auth) AuthTable(org.storymaker.app.model.AuthTable) Intent(android.content.Intent)

Aggregations

Auth (org.storymaker.app.model.Auth)14 AuthTable (org.storymaker.app.model.AuthTable)14 SiteController (io.scal.secureshare.controller.SiteController)6 Project (org.storymaker.app.model.Project)6 PublishJob (org.storymaker.app.model.PublishJob)6 Handler (android.os.Handler)4 File (java.io.File)4 Intent (android.content.Intent)3 SharedPreferences (android.content.SharedPreferences)2 Date (java.util.Date)2 Media (org.storymaker.app.model.Media)2 Bundle (android.os.Bundle)1 FragmentManager (android.support.v4.app.FragmentManager)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 ArchiveSiteController (io.scal.secureshare.controller.ArchiveSiteController)1 FacebookSiteController (io.scal.secureshare.controller.FacebookSiteController)1 FlickrSiteController (io.scal.secureshare.controller.FlickrSiteController)1 SSHSiteController (io.scal.secureshare.controller.SSHSiteController)1 SoundCloudSiteController (io.scal.secureshare.controller.SoundCloudSiteController)1 ChooseAccountFragment (io.scal.secureshare.lib.ChooseAccountFragment)1