⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppp_modem.cxx

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CXX
📖 第 1 页 / 共 5 页
字号:
/*                                                                        * Copyright (c) 2003 Century Software, Inc.   All Rights Reserved.      *                                                                        * This file is part of the PIXIL Operating Environment                  *                                                                        * The use, copying and distribution of this file is governed by one     * of two licenses, the PIXIL Commercial License, or the GNU General     * Public License, version 2.                                            *                                                                        * Licensees holding a valid PIXIL Commercial License may use this file  * in accordance with the PIXIL Commercial License Agreement provided    * with the Software. Others are governed under the terms of the GNU    * General Public License version 2.                                     *                                                                        * This file may be distributed and/or modified under the terms of the   * GNU General Public License version 2 as published by the Free         * Software Foundation and appearing in the file LICENSE.GPL included    * in the packaging of this file.                                       *                                                                        * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING   * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A             * PARTICULAR PURPOSE.                                                   *                                                                        * RESTRICTED RIGHTS LEGEND                                              *                                                                      * Use, duplication, or disclosure by the government is subject to       * restriction as set forth in paragraph (b)(3)(b) of the Rights in      * Technical Data and Computer Software clause in DAR 7-104.9(a).        *                                                                       * See http://www.pixil.org/gpl/ for GPL licensing        * information.                                                          *                                                                       * See http://www.pixil.org/license.html or               * email cetsales@centurysoftware.com for information about the PIXIL    * Commercial License Agreement, or if any conditions of this licensing  * are not clear to you.                                                 *//////////////////// Includes ////////////////////#include <FL/Fl.H>#include <FL/fl_draw.H>#include <FL/forms.H>#include <FL/Fl_Tabs.H>#include <FL/Fl_Menu_Item.H>extern "C"{#include <wm/ini.h>}#include "net_config.h"#include "ppp_modem.h"Fl_Menu_Item modemMenuItems[] = {    {"TCP/IP Setup", 0, NetConfig::show_ip},    {"DNS Setup", 0, NetConfig::show_dns},    {"Modem Setup", 0, NetConfig::show_modem},    {0},    {0}};Fl_Menu_Item setupMenuItems[] = {    {"Modem Setup", 0, NetConfig::show_modem},    {0},    {0}};/********************************ppp_add_account************************************///////////////////////////////////////////////////////////////// Functioin:           PPP_Add_Account::set_max_value()// Description: This function sets the max input lengths for//                                              inputs of PPP_Add_Account object// Parameters:          none// Returns:                     none///////////////////////////////////////////////////////////////voidPPP_Add_Account::set_max_values(){    add_general_account->maximum_size(19);    add_general_phone->maximum_size(11);    add_general_username->maximum_size(19);    add_general_password->maximum_size(19);}///////////////////////////////////////////////////////////////// Function:            PPP_Add_Account::set_account_value// Description: Sets the add_general_account input value// Parameters:          const chat *value// Returns:                     none///////////////////////////////////////////////////////////////voidPPP_Add_Account::set_account_value(const char *value){    add_general_account->value(value);}////////////////////////////////////////////////////////////// // Function:            PPP_Add_Account::set_pjone_value// Description: Sets the input value for add_general_phone// Parameters:          const chat *value// Returns:                     none/////////////////////////////////////////////////////////////voidPPP_Add_Account::set_phone_value(const char *value){    add_general_phone->value(value);}/////////////////////////////////////////////////////////////// Function:            PPP_Add_Account::set_username_value// Description: Sets the usernam input value// Parameters:          const chat *value// Returns:                     none//// ////////////////////////////////////////////////////////voidPPP_Add_Account::set_username_value(const char *value){    add_general_username->value(value);}/////////////////////////////////////////////////////////////// Functino:            PPP_Add_Accpunt::set_password_value// Description: sets the password input value// Paremeters:          const char *value// Returns:                     none/////////////////////////////////////////////////////////////voidPPP_Add_Account::set_password_value(const char *value){    add_general_password->value(value);}/////////////////////////////////////////////////////////////// Function:            PPP_Add_Account::get_account_value()// Description: get the account input value// Paremeters:          none// Returns:                     const char */////////////////////////////////////////////////////////////const char *PPP_Add_Account::get_account_value(){    return add_general_account->value();}///////////////////////////////////////////////////////////// // Funtion:                     PPP_Add_Account::get_phone_value// description: get the phone input value// Parameters:          none// Returns:                     const char */////////////////////////////////////////////////////////////const char *PPP_Add_Account::get_phone_value(){    return add_general_phone->value();}/////////////////////////////////////////////////////////////// Function:            PPP_Add_Account;;get_username_value// Description: get the username input value// Parameters:          none// returns:                     const char */////////////////////////////////////////////////////////////const char *PPP_Add_Account::get_username_value(){    return add_general_username->value();}/////////////////////////////////////////////////////////////// Function:            PPP_Add_Accoujnt::get_password_value// Description: get the passworkd input value// Parameters:          none// Returns:                     const chat */////////////////////////////////////////////////////////////const char *PPP_Add_Account::get_password_value(){    return add_general_password->value();}///////////////////////////////////////////////////////////////      Funtion:                        PPP_Add_Account::set_secret()//      Description:    set the password input to type secret//      Parameters:             none//      returns:                        none/////////////////////////////////////////////////////////////voidPPP_Add_Account::set_secret(){    add_general_password->type(FL_SECRET_INPUT);}/////////////////////////////////////////////////////////////// Funtions             PPP_Add_Account::PPP_Add_Account// Description: The PPP_Add_Account class instantiation// Parameters:          Fl_Tabs *add_account_tabs - pointer to parent tab// returns:                     none/////////////////////////////////////////////////////////////PPP_Add_Account::PPP_Add_Account(){    add_win = new NxPimWindow("Add Account", setupMenuItems, MENU);    NetConfig::I()->add_window((Fl_Window *) add_win->GetWindowPtr());    ok_button =	new NxButton(BUTTON_X, BUTTON_Y, BUTTON_WIDTH, BUTTON_HEIGHT, "Ok");    cancel_button =	new NxButton(BUTTON_X + BUTTON_WIDTH + 3, BUTTON_Y, BUTTON_WIDTH,		     BUTTON_HEIGHT, "Cancel");    add_general_group = new Fl_Group(W_X, W_Y, W_W, W_H);    add_general_group->add(ok_button);    add_general_group->add(cancel_button);    add_general_account = new NxInput(70, 65, 130, 20, "Account:");    add_general_phone = new NxInput(70, 90, 130, 20, "Number:");    add_general_username = new NxInput(70, 115, 130, 20, "Username:");    add_general_password = new NxInput(70, 140, 130, 20, "Password:");    add_general_group->end();    add_win->add((Fl_Widget *) add_general_group);    NxMenuButton *butt = (NxMenuButton *) (add_win->_menu);    butt->movable(true);    butt->resize(butt->x(), butt->y(), MB_W + 20, butt->h());    butt->movable(false);}/****************************ppp_account*******************************//////////////////////////////////////////////////////////////// Function:            PPP_Account::edit_account_value// description: Get input values from files based on which//                                              account is selected in the account browser// Parameters:          PPP_Add_Account *account - pointer to object// Returns:                     none///////////////////////////////////////////////////////////// voidPPP_Account::edit_account_value(PPP_Add_Account * account){    char account_value[20];    char phone[12] = "";    char password[20] = "";    char username[20] = "";    int val = 0;    val = ppp_account_browser->value();    if (0 >= val) {	return;    }    if (ppp_account_browser->text(val)) {	strcpy(account_value, ppp_account_browser->text(val));    } else {	strcpy(account_value, "");    }    IniGetString(account_value, "number", NULL, phone, sizeof(phone) - 1,		 ACCOUNT_FILE);    IniGetString(account_value, "password", NULL, password,		 sizeof(password) - 1, ACCOUNT_FILE);    IniGetString(account_value, "username", NULL, username,		 sizeof(username) - 1, ACCOUNT_FILE);    account->set_account_value(account_value);    account->set_phone_value(phone);    account->set_password_value(password);    account->set_username_value(username);}/////////////////////////////////////////////////////////////// Functions:           PPP_Account::change_account_value// Descrition:          Change the account value input to a value that//                                              has not been used yet// Parameters:          PPP_Add_Account *account - pointer to object// Returns:                     none//// ////////////////////////////////////////////////////////voidPPP_Account::change_account_value(PPP_Add_Account * account){    char buf[20];    bool match = true;    int accounts = ppp_account_browser->size();    int nums = 1;    sprintf(buf, "NewAccount%d", nums);    while (match) {	for (int idx = 1; idx <= accounts; idx++) {	    if (0 == strcmp(buf, ppp_account_browser->text(idx))) {		match = true;		idx = 0;		sprintf(buf, "NewAccount%d", ++nums);	    }	}	match = false;    }    account->set_account_value(buf);}/////////////////////////////////////////////////////////////// Funtions:            PPP_Account::get_account_value()// descrition:          get the account input value// Parameters:          PPP_Add_account *account - pointer to object// Returns:                     const chat */////////////////////////////////////////////////////////////const char *PPP_Account::get_account_value(PPP_Add_Account * account){    return account->get_account_value();}///////////////////////////////////////////////////////////////      Function:               PPP_Account::write_account()//      Description:    Write out the account values based on the value in//                                                      the account input//      Parameters;             PPP_Add_Account *account - pointer to an object//      returns:                        none/////////////////////////////////////////////////////////////voidPPP_Account::write_account(PPP_Add_Account * account){    char acnt[50];    char phone[20];    strcpy(acnt, account->get_account_value());    IniWriteString(acnt, "number", (char *) account->get_phone_value(),		   ACCOUNT_FILE);    IniWriteString(acnt, "username", (char *) account->get_username_value(),		   ACCOUNT_FILE);    IniWriteString(acnt, "password", (char *) account->get_password_value(),		   ACCOUNT_FILE);    sprintf(acnt, "Dialer %s", account->get_account_value());    strcpy(phone, account->get_phone_value());    IniWriteString(acnt, "Phone", phone, DIALER_FILE);    IniWriteString(acnt, "Username", (char *) account->get_username_value(),		   DIALER_FILE);    IniWriteString(acnt, "Password", (char *) account->get_password_value(),		   DIALER_FILE);    chmod(ACCOUNT_FILE, MODE_RDWR);}/////////////////////////////////////////////////////////////// Functoin:            PPP_Account::edit_account// Description: change the account value if it is "" and write out//                                              the account, and set parent inputs.// Parameters:          PPP_Add_Account *account - pointer to an object// Returns:                     none/////////////////////////////////////////////////////////////voidPPP_Account::edit_account(PPP_Add_Account * account){    char acnt[20];    strcpy(acnt, account->get_account_value());    if (0 == strcmp(acnt, "")) {	change_account_value(account);	strcpy(acnt, account->get_account_value());    }    for (int idx = 1; idx <= ppp_account_browser->size(); idx++) {	if (0 == strcmp(acnt, ppp_account_browser->text(idx))) {	    write_account(account);	    return;	}    }    fl_addto_browser(ppp_account_browser, acnt);    account_modem->add_account(acnt);    write_account(account);}/////////////////////////////////////////////////////////////// Function:            PPP_Account::add_account()// Description:   add account to account browser and write it out// Parameters:          PPP_Add_Accouht *account - pointer to an object

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -