Skip to content

Commit

Permalink
added CocoaMento
Browse files Browse the repository at this point in the history
  • Loading branch information
yun.er.run committed May 25, 2011
1 parent 5435e5c commit 6a9f9bf
Show file tree
Hide file tree
Showing 52 changed files with 6,191 additions and 0 deletions.
50 changes: 50 additions & 0 deletions CocoaMento-Src/CocoaMento.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#-------------------------------------------------
#
# Project created by QtCreator 2011-03-29T16:22:30
#
#-------------------------------------------------

QT += core gui network

CONFIG += qthread

TARGET = CocoaMento
TEMPLATE = app
LIBS += -framework Cocoa \
-framework Security \
-framework Growl

SOURCES += main.cpp\
statusicon.mm \
menuitem.mm \
cocoamenuitemvirtual.mm \
qtport.cpp \
cocoaappinitlizer.mm \
menuviewitem.mm\
menu.mm \
configview.cpp \
mento.cpp \
accountform.cpp \
mentothread.cpp \
guite.cpp

HEADERS += \
statusicon.h \
menuitem.h \
cocoamenuitemvirtual.h \
qtport.h \
cocoaappinitlizer.h \
menuviewitem.h \
menu.h \
configview.h \
mento.h \
accountform.h \
mentothread.h \
guite.h \

FORMS += \
configview.ui \
accountform.ui \
guite.ui

RESOURCES +=
113 changes: 113 additions & 0 deletions CocoaMento-Src/CocoaMento.pro.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<!DOCTYPE QtCreatorProject>
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value key="EditorConfiguration.Codec" type="QByteArray">System</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Desktop</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
<value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">1</value>
<value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
<valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
<valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
</valuemap>
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
</valuemap>
<value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
<valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
<value type="QString">clean</value>
</valuelist>
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
</valuemap>
<value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
<value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
<valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Debug</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/Users/shanzi/Documents/Codes/CocoaMento-build-desktop</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
</valuemap>
<valuemap key="ProjectExplorer.Target.BuildConfiguration.1" type="QVariantMap">
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
<valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
</valuemap>
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
</valuemap>
<value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
<valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
<value type="QString">clean</value>
</valuelist>
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
</valuemap>
<value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
<value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
<valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Release</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/Users/shanzi/Documents/Codes/CocoaMento-build-desktop</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
</valuemap>
<value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">2</value>
<valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">CocoaMento</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase" type="int">2</value>
<valuelist key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QVariantList"/>
<value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">CocoaMento.pro</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
<valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetName" type="bool">false</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory" type="bool">false</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString"></value>
</valuemap>
<value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">4</value>
</data>
</qtcreator>
15 changes: 15 additions & 0 deletions CocoaMento-Src/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CocoaMento是一个使用Cocoa和Qt代码混合编写的校园网登陆客户端图形界面加壳程序,目前只适用于Mac OS X,在10.6以上版本测试通过。

编译注意事项

1,因为使用Qt框架,编译前需前往Qt官网下载Qt SDK,届时打开CocoaMento.pro文件直接编译即可。
2,为了方便mentohust进程和GUI的交互,对mentohust代码略有修改,主要修改在于更改了程序向外输出的字符串。代码在mentohust-src文件夹中,只需在对应目录下执行make命令即可
3,mentohust-src/auth.c是为了在Mac OS下完成对程序权限的申请而特制的一个小程序,使用gcc auth.c -o auth命令直接编译即可
4,最新版本的CocoaMento加入了Growl框架的支持,编译前请先下载配置开源的Growl SDK

打包注意事项

1,Mac OS的App存放在bundle结构的目录体系下,编译好以后,应将编译所得的mentohust文件和auth文件移动到Contents/MacOS/目录下。
2,为了方便权限管理,采用了私用pcap的方法,请将系统内的libpcap.dylib库复制或制作快捷连接,放置于Contents/Frameworks目录下
3,程序的Contents/Resources文件夹内可以存放图标等资源,Contents/Resources/data/文件夹是默认存放官方锐捷数据文件的目录

33 changes: 33 additions & 0 deletions CocoaMento-Src/StatusIcon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// StatusIcon.h
// HelloCocoa
//
// Created by 云尔 on 11-3-28.
// Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#ifndef _STATUS_ICON_H
#define _STATUS_ICON_H
#include "menu.h"
#include <QString>

class StatusIcon
{
public:
StatusIcon();
~StatusIcon();
void showIcon();
void hideIcon();
void setHighlightMode(bool highlight);
bool highlightMode();
void setMenu(Menu* menu);
void setIcon(const char* name);

private:
Menu* menu;
class CocoaBridge;
CocoaBridge* b;
};


#endif
17 changes: 17 additions & 0 deletions CocoaMento-Src/StatusIconBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// StatusIconBase.h
// HelloCocoa
//
// Created by 云尔 on 11-3-29.
// Copyright 2011年 __MyCompanyName__. All rights reserved.
//
#ifndef STATUS_ICON_BASE
#define STATUS_ICON_BASE


//class StatusIconBase; {
//public:
// void handleTrigger(long id);
//};

#endif
136 changes: 136 additions & 0 deletions CocoaMento-Src/accountform.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#include "accountform.h"
#include "ui_accountform.h"
#include <QDebug>

static const unsigned char base64Tab[] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"};
static const char xorRuijie[] = {"~!:?$*<(qw2e5o7i8x12c6m67s98w43d2l45we82q3iuu1z4xle23rt4oxclle34e54u6r8m"};

static int encodePass(char *dst, const char *osrc) {
unsigned char in[3], buf[70];
unsigned char *src = buf;
int sz = strlen(osrc);
int i, len;
if (sizeof(xorRuijie) < sz)
return -1;
for(i=0; i<sz; i++)
src[i] = osrc[i] ^ xorRuijie[i];
while (sz > 0) {
for (len=0, i=0; i<3; i++, sz--) {
if (sz > 0) {
len++;
in[i] = src[i];
} else in[i] = 0;
}
src += 3;
if (len) {
dst[0] = base64Tab[ in[0] >> 2 ];
dst[1] = base64Tab[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ];
dst[2] = len > 1 ? base64Tab[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] : '=';
dst[3] = len > 2 ? base64Tab[ in[2] & 0x3f ] : '=';
dst += 4;
}
}
*dst = '\0';
return 0;
}

static int decodePass(char *dst, const char *src) {
unsigned esi = 0, idx = 0;
int i=0, j=0, equal=0;
for(; src[i]!='\0'; i++) {
if (src[i] == '=') {
if (++equal > 2)
return -1;
} else {
for(idx=0; base64Tab[idx]!='\0'; idx++) {
if(base64Tab[idx] == src[i])
break;
}
if (idx == 64)
return -1;
esi += idx;
}
if(i%4 == 3) {
dst[j++] = (char)(esi>>16);
if(equal < 2)
dst[j++] = (char)(esi>>8);
if(equal < 1)
dst[j++] = (char)esi;
esi = 0;
equal = 0;
}
esi <<= 6;
}
if (i%4!=0 || sizeof(xorRuijie)<j)
return -1;
for(i=0; i<j; i++)
dst[i] ^= xorRuijie[i];
dst[j] = '\0';
return 0;
}


AccountForm::AccountForm(QSettings *settingref, QWidget *parent) :
QWidget(parent),
ui(new Ui::AccountForm)
{
ui->setupUi(this);
setWindowFlags(Qt::WindowStaysOnTopHint|Qt::CustomizeWindowHint|Qt::WindowCloseButtonHint);
ref=settingref;
connect(ui->Cancel,SIGNAL(clicked()),this,SLOT(close()));
connect(ui->Confirm,SIGNAL(clicked()),this,SLOT(Confirm()));
connect(ui->Name,SIGNAL(returnPressed()),this,SLOT(Confirm()));
connect(ui->Pass,SIGNAL(returnPressed()),this,SLOT(Confirm()));
}

AccountForm::~AccountForm()
{
delete ui;
}

void AccountForm::setAccount(const char *name, const char *pass)
{
char pw[65*4/3]={0};
if(ref==0)return;
if(name!=0) ref->setValue(tr("Username"),tr(name));
if(pass!=0)
{

if(encodePass(pw,pass))
{
QMessageBox::critical(this,"错误","设定密码失败,无法进行加密操作!",QMessageBox::Cancel,QMessageBox::NoButton);
return;
}
ref->setValue(tr("EncodePass"),tr(pw));
}
if(!ref->isWritable()){
QMessageBox::critical(this,"错误","写入配置文件失败!",QMessageBox::Cancel,QMessageBox::NoButton);
return;
}
ui->Name->setText(ref->value(tr("Username")).toString());
//qDebug()<<ref->value(tr("Username")).toString();
if(decodePass(pw,ref->value(tr("EncodePass")).toString().toUtf8().data()))
{
QMessageBox::critical(this,"错误","解析密码失败!请重设密码!",QMessageBox::Ok,QMessageBox::NoButton);
ui->Pass->setText(tr(""));
ref->remove(tr("EncodePass"));
this->show();
}
else ui->Pass->setText(tr(pw));
}
void AccountForm::show()
{
setAccount();
QWidget::show();
}

void AccountForm::Confirm()
{
if(ui->Name->text().length()==0 || ui->Pass->text().length()==0)
{
QMessageBox::warning(this,"Warning","用户名和密码不能为空!",QMessageBox::Ok,QMessageBox::NoButton);
return;
}
setAccount(ui->Name->text().toUtf8().data(),ui->Pass->text().toUtf8().data());
QWidget::close();
}
Loading

0 comments on commit 6a9f9bf

Please sign in to comment.