to_be_down.cpp

/*****************************************************************************
 *
 *      Impletement about AllanYan's getting ftp resources from nju campus
 *
 *      (C) Copyleft 2007, AllanYan from Nanjing University, P.R.China
 *      Author : S.C.Yan                Last Modified @ 2007.07.27
 *
 *      Public Interface : no
 *
 *      Abstract : about AllanYan's getting some ftp resources from nju campus
 *
 *****************************************************************************/

#include <nju.h>
#include <NJUer.h>
#include <ftp.h>

// possible candidates
#include "yxf760321.h"
#include "XiaKai.h"
#include "ZhouWei.h"
#include "YeSuLi.h"
#include "zch312.h"

#include "AllanYan.h"
#include "misc.h"

// using Unix-style C++
#ifndef UNIX_STYLE_CPP
 #define UNIX_STYLE_CPP yes
#endif

using namespace std;

namespace AllanYan
{
  /**
   * get_American_Seasons : get American Season by giving name and season no.
   * @param tvplay_name : the pointor to the char season name
   * @param season : the season No, in format of short integer
   * @param njuer : reference to some NJUer to perform the action
   * @param mdisk : reference to some MobileDevice for the resource to download into
   * @return true when login is successful, or false when not
   */
  bool get_American_Seasons(char const *tvplay_name,
                            short season,
                            NJUer &njuer,
                            MobileDevice &mdisk)
  {
    if(njuer.login("ftp://media.nju.edu.cn"))
    {
      if(njuer.check_dev_state(mdisk) && /
          njuer.find_where_American_Seasons_is())
      {
        njuer.get_American_Seasons(tvplay_name,season);
      }
      return true;
    }
    return false;
  }

  /**
   * get_Oscar_best_movies : get Oscar best movies by providing the No.
   * @param begin_no : the beginning No. of the Oscar best movie to be downloaded
   * @param end_no : the ending No. of the Oscar best movie to be downloaded
   * @param njuer : reference to some NJUer to perform the action
   * @param mdisk : reference to some MobileDevice for the resource to download into
   * @return true on no error, or false when any exception happends
   */
  bool get_Oscar_best_movies(short begin_no,
                             short end_no,
                             NJUer &njuer,
                             MobileDevice &mdisk)
  {
    if(njuer.login("ftp://****:*********@rise.nju.edu.cn"))
    {
      if(njuer.check_dev_state(mdisk) &&  /
          njuer.find_where_Oscar_best_movies_is())
      {
        for(short oscar_no=1;oscar_no<78;oscar_no++)
        {
          if(njuer.check_dev_state(mdisk))
          {
            njuer.get_Oscar_best_movies(oscar_no);
          }
          else return true;
        }
      }
    }
    return true;
  }

  /**
  * get_KaraOK_files : invoke njuer to download KaraOK files into the mobile device
  * @param njuer : reference to some NJUer to perform the action
  * @param mdisk : reference to some MobileDevice for the resource to download into
  * @return true on no error, or false when any exception happends
  */
  bool get_KaraOK_files(NJUer &njuer,MobileDevice &mdisk)
  {
    if(njuer.login("ftp://cos.nju.edu.cn/Music"))
    {
      if(njuer.check_dev_state(mdisk) && /
          njuer.find_where_KaraOK_files_is())
      {
        njuer.get_KaraOK_files("*.zip");
        njuer.get_KaraOK_files("*.rar");
        njuer.get_KaraOK_files("*.mp3");
      }
    }
    return true;
  }

  // process entry
  int main (int argc, char* argv[])
  {

    bool ret = false;

    try
    {
      // get singlton instance from possible candidate
      char const * freind = AllanYan::get_freind_from_memory(); // "mirth"
      NJUer &njuer = (NJUer &)*NJUer::get_njuer_from_LilyBBS_by_id(freind);
      MobileDevice &mdisk = (MobileDevice &)*AllanYan::get_mdev_instance();

      AllanYan::send_mdev_to(njuer,AllanYan::get_spare_time());

      // get things --- the importants of all
      ret = get_American_Seasons("Heroes",1,njuer,mdisk) || /
            get_American_Seasons("X Files",1,njuer,mdisk) || /
            get_Oscar_best_movies(1,77,njuer,mdisk) || /
            get_KaraOK_files(njuer,mdisk);

      // short msg to allanyan's cellphone when things got done
      njuer.send_sms_to(AllanYan::get_instance(),"downloads finished.");
      AllanYan::get_mdev_back();

      // the rewards back to njuer
      if(ret)
      {
        AllanYan::send_bg_invitation(njuer,"a meal");
        AllanYan::say_to(njuer,"a great many thanks.");
      }
      else
      {
        njuer.da_pp(njuer.get_foot(),njuer.pp,"kick your ass");

        if(njuer.still_feel_good())
        {
          AllanYan::send_bg_invitation(njuer,"a icecream");
          AllanYan::say_to(njuer,"a great many fts.");
        }
      }
    }
    catch(exception ex)
    {
      cout << "Ooops~~Oh-o~~!" << endl;
    }
    return ret ? 0:1;
  }
}

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值