private Object uploadFileHelper(Object[] params, final File tempFile) {
      // Create listener for tracking upload progress in the notification
      if (mClient instanceof XMLRPCClient) {
        XMLRPCClient xmlrpcClient = (XMLRPCClient) mClient;
        xmlrpcClient.setOnBytesUploadedListener(
            new XMLRPCClient.OnBytesUploadedListener() {
              @Override
              public void onBytesUploaded(long uploadedBytes) {
                if (tempFile.length() == 0) {
                  return;
                }
                float percentage = (uploadedBytes * 100) / tempFile.length();
                mPostUploadNotifier.updateNotificationProgress(percentage);
              }
            });
      }

      try {
        return mClient.call(ApiHelper.Methods.UPLOAD_FILE, params, tempFile);
      } catch (XMLRPCException e) {
        AppLog.e(T.API, e);
        mErrorMessage =
            mContext.getResources().getString(R.string.error_media_upload) + ": " + e.getMessage();
        return null;
      } catch (IOException e) {
        AppLog.e(T.API, e);
        mErrorMessage =
            mContext.getResources().getString(R.string.error_media_upload) + ": " + e.getMessage();
        return null;
      } catch (XmlPullParserException e) {
        AppLog.e(T.API, e);
        mErrorMessage =
            mContext.getResources().getString(R.string.error_media_upload) + ": " + e.getMessage();
        return null;
      } finally {
        // remove the temporary upload file now that we're done with it
        if (tempFile != null && tempFile.exists()) {
          tempFile.delete();
        }
      }
    }
  public String getCategories() {
    // gets the categories via xmlrpc call to wp blog
    String returnMessage = "";

    Object result[] = null;

    Object[] params = {
      blog.getBlogId(), blog.getUsername(), blog.getPassword(),
    };

    client = new XMLRPCClient(blog.getUrl(), blog.getHttpuser(), blog.getHttppassword());

    boolean success = false;

    try {
      result = (Object[]) client.call("wp.getCategories", params);
      success = true;
    } catch (XMLRPCException e) {
      e.printStackTrace();
    }

    if (success) {
      int size = result.length;

      // wipe out the categories table
      WordPress.wpDB.clearCategories(id);

      for (int i = 0; i < size; i++) {
        Map<?, ?> curHash = (Map<?, ?>) result[i];

        String categoryName = curHash.get("categoryName").toString();
        String categoryID = curHash.get("categoryId").toString();

        int convertedCategoryID = Integer.parseInt(categoryID);

        WordPress.wpDB.insertCategory(id, convertedCategoryID, categoryName);

        // populate the spinner with the category names
        textArray.add(categoryName);
      }

      returnMessage = "gotCategories";
    } else {
      returnMessage = "FAIL";
    }

    return returnMessage;
  }
  /**
   * function addCategory
   *
   * @param String category_name
   * @return
   * @description Adds a new category
   */
  public String addCategory(
      String category_name, String category_slug, String category_desc, int parent_id) {
    // Return string
    String returnString = "";

    // Store the parameters for wp.addCategory
    Map<String, Object> struct = new HashMap<String, Object>();
    struct.put("name", category_name);
    struct.put("slug", category_slug);
    struct.put("description", category_desc);
    struct.put("parent_id", parent_id);

    client = new XMLRPCClient(blog.getUrl(), blog.getHttpuser(), blog.getHttppassword());

    Object[] params = {blog.getBlogId(), blog.getUsername(), blog.getPassword(), struct};

    Object result = null;
    try {
      result = client.call("wp.newCategory", params);
    } catch (XMLRPCException e) {
      e.printStackTrace();
    }

    if (result == null) {
      returnString = "addCategory_failed";
    } else {
      // Category successfully created. "result" is the ID of the new category
      // Initialize the category database
      // Convert "result" (= category_id) from type Object to int
      int category_id = Integer.parseInt(result.toString());
      // Insert the new category into database
      WordPress.wpDB.insertCategory(id, category_id, category_name);

      returnString = "addCategory_success";
    }

    return returnString;
  }
  private void replyToComment(final String postID, final int commentID, final String comment) {
    // reply to individual comment
    client =
        new XMLRPCClient(
            WordPress.currentBlog.getUrl(),
            WordPress.currentBlog.getHttpuser(),
            WordPress.currentBlog.getHttppassword());

    Map<String, Object> replyHash = new HashMap<String, Object>();
    replyHash.put("comment_parent", commentID);
    replyHash.put("content", comment);
    replyHash.put("author", "");
    replyHash.put("author_url", "");
    replyHash.put("author_email", "");

    Object[] params = {
      WordPress.currentBlog.getBlogId(),
      WordPress.currentBlog.getUsername(),
      WordPress.currentBlog.getPassword(),
      Integer.valueOf(postID),
      replyHash
    };

    try {
      int newCommentID = (Integer) client.call("wp.newComment", params);
      if (newCommentID >= 0) {
        WordPress.wpDB.updateLatestCommentID(WordPress.currentBlog.getId(), newCommentID);
      }
      dismissDialog(ID_DIALOG_REPLYING);
      Thread action =
          new Thread() {
            public void run() {
              Toast.makeText(
                      CommentsActivity.this,
                      getResources().getText(R.string.reply_added),
                      Toast.LENGTH_SHORT)
                  .show();
            }
          };
      runOnUiThread(action);
      Thread action2 =
          new Thread() {
            public void run() {
              pd = new ProgressDialog(CommentsActivity.this); // to avoid
              // crash
              commentList.refreshComments(false, true, false);
            }
          };
      runOnUiThread(action2);

    } catch (final XMLRPCException e) {
      dismissDialog(ID_DIALOG_REPLYING);
      Thread action3 =
          new Thread() {
            public void run() {

              Toast.makeText(
                      CommentsActivity.this,
                      getResources().getText(R.string.connection_error),
                      Toast.LENGTH_SHORT)
                  .show();

              Intent i = new Intent(CommentsActivity.this, AddCommentActivity.class);
              i.putExtra("commentID", commentID);
              i.putExtra("postID", WordPress.currentComment.postID);
              i.putExtra("comment", comment);
              startActivityForResult(i, 0);
            }
          };
      runOnUiThread(action3);
    }
  }
  private void deleteComment(int selCommentID) {
    // delete individual comment

    client =
        new XMLRPCClient(
            WordPress.currentBlog.getUrl(),
            WordPress.currentBlog.getHttpuser(),
            WordPress.currentBlog.getHttppassword());

    Object[] params = {
      WordPress.currentBlog.getBlogId(),
      WordPress.currentBlog.getUsername(),
      WordPress.currentBlog.getPassword(),
      selCommentID
    };

    try {
      client.call("wp.deleteComment", params);
      dismissDialog(ID_DIALOG_DELETING);
      attemptToSelectComment();
      Thread action =
          new Thread() {
            public void run() {
              Toast.makeText(
                      CommentsActivity.this,
                      getResources().getText(R.string.comment_moderated),
                      Toast.LENGTH_SHORT)
                  .show();
            }
          };
      runOnUiThread(action);
      Thread action2 =
          new Thread() {
            public void run() {
              pd = new ProgressDialog(CommentsActivity.this);
              commentList.refreshComments(false, true, false);
            }
          };
      runOnUiThread(action2);

    } catch (final XMLRPCException e) {
      dismissDialog(ID_DIALOG_DELETING);
      Thread action3 =
          new Thread() {
            public void run() {
              AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(CommentsActivity.this);
              dialogBuilder.setTitle(getResources().getText(R.string.connection_error));
              dialogBuilder.setMessage(getResources().getText(R.string.error_moderate_comment));
              dialogBuilder.setPositiveButton(
                  "OK",
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                      // Just close the window.

                    }
                  });
              dialogBuilder.setCancelable(true);
              if (!isFinishing()) {
                dialogBuilder.create().show();
              }
            }
          };
      runOnUiThread(action3);
    }
  }
  @SuppressWarnings("unchecked")
  private void changeCommentStatus(final String newStatus, final int selCommentID) {
    // for individual comment moderation
    client =
        new XMLRPCClient(
            WordPress.currentBlog.getUrl(),
            WordPress.currentBlog.getHttpuser(),
            WordPress.currentBlog.getHttppassword());

    Map<String, String> contentHash, postHash = new HashMap<String, String>();
    contentHash = (Map<String, String>) commentList.allComments.get(selCommentID);
    postHash.put("status", newStatus);
    postHash.put("content", contentHash.get("comment"));
    postHash.put("author", contentHash.get("author"));
    postHash.put("author_url", contentHash.get("url"));
    postHash.put("author_email", contentHash.get("email"));

    Object[] params = {
      WordPress.currentBlog.getBlogId(),
      WordPress.currentBlog.getUsername(),
      WordPress.currentBlog.getPassword(),
      selCommentID,
      postHash
    };

    Object result = null;
    try {
      result = (Object) client.call("wp.editComment", params);
      boolean bResult = Boolean.parseBoolean(result.toString());
      if (bResult) {
        WordPress.currentComment.status = newStatus;
        commentList.model.set(WordPress.currentComment.position, WordPress.currentComment);
        WordPress.wpDB.updateCommentStatus(id, WordPress.currentComment.commentID, newStatus);
        contentHash.put("status", newStatus);
      }
      dismissDialog(ID_DIALOG_MODERATING);
      Thread action =
          new Thread() {
            public void run() {
              Toast.makeText(
                      CommentsActivity.this,
                      getResources().getText(R.string.comment_moderated),
                      Toast.LENGTH_SHORT)
                  .show();
            }
          };
      runOnUiThread(action);
      Thread action2 =
          new Thread() {
            public void run() {
              commentList.getListView().invalidateViews();
            }
          };
      runOnUiThread(action2);

    } catch (final XMLRPCException e) {
      dismissDialog(ID_DIALOG_MODERATING);
      Thread action3 =
          new Thread() {
            public void run() {
              AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(CommentsActivity.this);
              dialogBuilder.setTitle(getResources().getText(R.string.connection_error));
              dialogBuilder.setMessage(getResources().getText(R.string.error_moderate_comment));
              dialogBuilder.setPositiveButton(
                  "OK",
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                      // Just close the window.

                    }
                  });
              dialogBuilder.setCancelable(true);
              if (!isFinishing()) {
                dialogBuilder.create().show();
              }
            }
          };
      runOnUiThread(action3);
    }
  }