// Path: src/com/zlab/datFM/swiftp/FtpServerApp.java
// public class FtpServerApp extends Application {
// 
//     private static final String TAG = FtpServerApp.class.getSimpleName();
// 
//     private static Context sContext;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         sContext = getApplicationContext();
//     }
// 
//     /**
//      * @return the Context of this application
//      */
//     public static Context getAppContext() {
//         if (sContext == null){
//             Log.e(TAG, "Global context not set");
//             sContext = datFM.datFM_context;
//         }
//         return sContext;
//     }
// 
//     /**
//      * @return true if this is the free version
//      */
//     public static boolean isFreeVersion() {
//         try {
//             Context context = getAppContext();
//             return context.getPackageName().contains("free");
//         } catch (Exception swallow) {
//         }
//         return false;
//     }
// 
//     /**
//      * Get the version from the manifest.
//      * 
//      * @return The version as a String.
//      */
//     public static String getVersion() {
//         Context context = getAppContext();
//         String packageName = context.getPackageName();
//         try {
//             PackageManager pm = context.getPackageManager();
//             return pm.getPackageInfo(packageName, 0).versionName;
//         } catch (NameNotFoundException e) {
//             Log.e(TAG, "Unable to find the name " + packageName + " in the package");
//             return null;
//         }
//     }
// 
// }


import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import com.zlab.datFM.swiftp.FtpServerApp;
/*
Copyright 2009 David Revell

This file is part of SwiFTP.

SwiFTP 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.

SwiFTP 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 SwiFTP.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.zlab.datFM.swiftp.server;


public class CmdPASS extends FtpCmd implements Runnable {
    private static final String TAG = CmdPASS.class.getSimpleName();

    String input;

    public CmdPASS(SessionThread sessionThread, String input) {
        // We can just discard the password for now. We're just
        // following the expected dialogue, we're going to allow
        // access in any case.
        super(sessionThread);
        this.input = input;
    }

    @Override
    public void run() {
        Log.d(TAG, "Executing PASS");
        // User must have already executed a USER command to
        // populate the Account object's username
        String attemptPassword = getParameter(input, true); // silent
        String attemptUsername = sessionThread.account.getUsername();
        if (attemptUsername == null) {
            sessionThread.writeString("503 Must send USER first\r\n");
            return;
        }
// Path: src/com/zlab/datFM/swiftp/FtpServerApp.java
// public class FtpServerApp extends Application {
// 
//     private static final String TAG = FtpServerApp.class.getSimpleName();
// 
//     private static Context sContext;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         sContext = getApplicationContext();
//     }
// 
//     /**
//      * @return the Context of this application
//      */
//     public static Context getAppContext() {
//         if (sContext == null){
//             Log.e(TAG, "Global context not set");
//             sContext = datFM.datFM_context;
//         }
//         return sContext;
//     }
// 
//     /**
//      * @return true if this is the free version
//      */
//     public static boolean isFreeVersion() {
//         try {
//             Context context = getAppContext();
//             return context.getPackageName().contains("free");
//         } catch (Exception swallow) {
//         }
//         return false;
//     }
// 
//     /**
//      * Get the version from the manifest.
//      * 
//      * @return The version as a String.
//      */
//     public static String getVersion() {
//         Context context = getAppContext();
//         String packageName = context.getPackageName();
//         try {
//             PackageManager pm = context.getPackageManager();
//             return pm.getPackageInfo(packageName, 0).versionName;
//         } catch (NameNotFoundException e) {
//             Log.e(TAG, "Unable to find the name " + packageName + " in the package");
//             return null;
//         }
//     }
// 
// }


// Path: src/com/zlab/datFM/swiftp/server/CmdPASS.java
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import com.zlab.datFM.swiftp.FtpServerApp;

/*
Copyright 2009 David Revell

This file is part of SwiFTP.

SwiFTP 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.

SwiFTP 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 SwiFTP.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.zlab.datFM.swiftp.server;


public class CmdPASS extends FtpCmd implements Runnable {
    private static final String TAG = CmdPASS.class.getSimpleName();

    String input;

    public CmdPASS(SessionThread sessionThread, String input) {
        // We can just discard the password for now. We're just
        // following the expected dialogue, we're going to allow
        // access in any case.
        super(sessionThread);
        this.input = input;
    }

    @Override
    public void run() {
        Log.d(TAG, "Executing PASS");
        // User must have already executed a USER command to
        // populate the Account object's username
        String attemptPassword = getParameter(input, true); // silent
        String attemptUsername = sessionThread.account.getUsername();
        if (attemptUsername == null) {
            sessionThread.writeString("503 Must send USER first\r\n");
            return;
        }
        Context ctx = FtpServerApp.getAppContext();