qq宣传源码

热门资讯  点击:   2013-08-01

qq宣传源码篇一

QQ源代码

QQ源代码

// MyQQ.cpp: implementation of the MyQQ class.

//////////////////////////////////////////////////////////////////////

#include

#include

#include "winsock2.h"

#include "MyQQ.h"

#include "md5.h"

#ifdef _DEBUG

#undef THIS_FILE

static char THIS_FILE[]=__FILE__;

#define new DEBUG_NEW

#endif

//////////////////////////////////////////////////////////////////////

// Construction/Destruction

//////////////////////////////////////////////////////////////////////

MyQQ::MyQQ()

{

s = NULL;

LoginToken = NULL;

LoginTokenLength = 0;

Status = 0; //下线

IsLogin = false;

LastID = 0;

MessageText = NULL;

FriendListHead = NULL;

FriendListTail = NULL;

send_seq = random() & 0x0000ffff;

LastOnline = time(NULL);

UDPServerNum = 0;

//服务器地址

LoginServer = (char *)malloc(16*sizeof(char));

//QQ号

UserID = 0;

//密码

Password = NULL;

//得到初始化密钥,按2004版

InitKey = (unsigned char*)malloc(QQ_KEY_LENGTH);

int i;

for(i = 0; i < 16; i++)

InitKey = rand();

SessionKey = (unsigned char*)malloc(QQ_KEY_LENGTH);

}

MyQQ::~MyQQ()

{

if(LoginServer != NULL)

free(LoginServer);

if(MyIP != NULL)

free(MyIP);

if(MessageText != NULL)

free(MessageText);

if(Password != NULL)

free(Password);

if(InitKey != NULL)

free(InitKey);

if(PwdKey != NULL)

free(PwdKey);

if(SessionKey != NULL)

free(SessionKey);

if(FriendListHead != NULL)

{

QQFriend *p = FriendListHead->next;

while(p != NULL)

{

free(FriendListHead);

FriendListHead = p;

p = p->next;

}

if(FriendListTail != NULL)

free(FriendListTail);

}

}

void MyQQ::Login(int pMode)

{

unsigned char *buf, *cursor, *raw_data, *encrypted_data;

int seq_ret;

int encrypted_len, bytes;

//登录模式:1 为正常登录,2为隐身登录 ,3登录即离开

LoginMode = pMode;

if(LoginToken == NULL)

{

//发送获取登录令牌的包

qq_get_logintoken();

}

else

{

//2004登录包

buf = (unsigned char*)malloc(MAX_PACKAGE_LENGTH); //包长65535 raw_data = (unsigned char*)malloc(QQ_LOGIN_DATA_LENGTH); //数据长

encrypted_data = (unsigned char*)malloc(QQ_LOGIN_DATA_LENGTH + 16); //加密数据长度多16

// 产生密文

// 000-015 用PwdKey加密空串

MCrypter.qq_crypt(ENCRYPT, (unsigned char*)"", 0, PwdKey, raw_data, &encrypted_len);

//016-051 36字节的固定内容

memmove(raw_data + 16, login_16_51, 36);

//052-052 登录方式

raw_data[52] = (unsigned char)LoginMode;

//053-068 16字节固定内容

memmove(raw_data + 53, login_53_68, 16);

//069 登录令牌长度

int pos = 69;

raw_data[pos++] = (unsigned char)LoginTokenLength;

//070-? 登录令牌

memmove(raw_data + pos, LoginToken, LoginTokenLength);

pos += LoginTokenLength;

//未知字节0x40

raw_data[pos++] = 0x40;

//固定字节

memmove(raw_data + pos, LOGIN_SEGMENTS, 100);

pos += 100;

//剩下的字节填零

for(; pos < QQ_LOGIN_DATA_LENGTH; pos++)

raw_data[pos] = 0x00;

//加密

MCrypter.qq_crypt(ENCRYPT, raw_data, QQ_LOGIN_DATA_LENGTH, InitKey, encrypted_data, &encrypted_len);

cursor = buf;

bytes = 0;

bytes += create_packet_head_seq(buf, &cursor, QQ_CMD_LOGIN, true, &seq_ret);

bytes += create_packet_dw(buf, &cursor, UserID);

bytes += create_packet_data(buf, &cursor, InitKey, QQ_KEY_LENGTH); bytes += create_packet_data(buf, &cursor, encrypted_data, encrypted_len); bytes += create_packet_b(buf, &cursor, QQ_PACKET_TAIL);

if (bytes == (cursor - buf)) //包被无误创建

{

qq_send_packet(buf, bytes, QQ_CMD_LOGIN);

}

free(buf);

free(raw_data);

free(encrypted_data);

}

}

//从包中读取一个字节

int MyQQ::read_packet_b(unsigned char * buf, unsigned char ** cursor, int buflen, unsigned char * b)

{

if(*cursor <= buf + buflen - sizeof(*b))

{

*b = **(unsigned char **) cursor;

*cursor += sizeof(*b);

return sizeof(*b);

}

else

return -1;

}

//从包中读取一个字

int MyQQ::read_packet_w(unsigned char * buf, unsigned char ** cursor, int buflen, short * w)

{

if(*cursor <= buf + buflen - sizeof(*w))

{

*w = ntohs(**(short **) cursor);

*cursor += sizeof(*w);

return sizeof(*w);

} else

return -1;

}

//处理收到的消息

void MyQQ::qq_process_recv_im(unsigned char* buf, int buf_len, short seq)

{

int len, bytes;

unsigned char *data, *cursor;

qq_recv_im_header *im_header;

len = buf_len;

data = (unsigned char *)malloc(len);

if (MCrypter.qq_crypt(DECRYPT, buf, buf_len, SessionKey, data, &len))

{

if(len < 16)

return;

else

qq_send_packet_recv_im_ack(seq, data);

cursor = data;

bytes = 0;

im_header = (qq_recv_im_header *)malloc(sizeof(qq_recv_im_header)); bytes += read_packet_dw(data, &cursor, len, &(im_header->sender_uid)); bytes += read_packet_dw(data, &cursor, len, &(im_header->receiver_uid)); bytes += read_packet_dw(data, &cursor, len, &(im_header->server_im_seq));

bytes += read_packet_data(data, &cursor, len, (unsigned char *) (im_header->sender_ip), 4);

bytes += read_packet_w(data, &cursor, len, &(im_header->sender_port)); bytes += read_packet_w(data, &cursor, len, &(im_header->im_type));

if (bytes != 20) { // im_header的长度

return; &

qq宣传源码篇二

qq源代码

UserHelper..cs类代码

using System;

using System.Collections.Generic;

using System.Text;

namespace MyQQ

{

//记录登录的用户Id

class UserHelper

{

public static int loginId; //登录的用户Id

}

}

using System;

using System.Collections.Generic;

using System.ComponentModel;

{qq宣传源码}.

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace MyQQ

{

/// <summary>

/// 聊天窗体

/// </summary>

public partial class ChatForm : Form

{

public int friendId; // 当前聊天的好友号码

public string nickName; // 当前聊天的好友昵称

public int faceId; // 当前聊天的好友头像Id

public ChatForm()

{

InitializeComponent();

}

// 窗体加载时的动作

private void ChatForm_Load(object sender, EventArgs e)

{

// 设置窗体标题

this.Text = string.Format("与{0}聊天中",nickName);

// 设置窗体顶部显示的好友信息

picFace.Image = ilFaces.Images[faceId];

lblFriend.Text = string.Format("{0}({1})",nickName,friendId);

// 读取所有的未读消息,显示在窗体中

ShowMessage();

}

// 关闭窗体

private void btnClose_Click(object sender, EventArgs e)

{

this.Close();

}

// 发送消息

private void btnSend_Click(object sender, EventArgs e)

{

if (txtChat.Text.Trim() == "") // 不能发送空消息

{

MessageBox.Show("不能发送空消息!", "提示", MessageBoxButtons.OK,

MessageBoxIcon.Information);

return;

}

else if (txtChat.Text.Trim().Length > 50)

{

MessageBox.Show("消息内容过长,请分为几条发送!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

return;

}

else // 发送消息,写入数据库{qq宣传源码}.

{

// MessageTypeId:1-表示聊天消息,为简化操作没有读取数据表,到S2可以用常量或者枚举实现

// MessageState:0-表示消息状态是未读

int result = -1; // 表示操作数据库的结果

string sql = string.Format(

"INSERT INTO Messages (FromUserId, ToUserId, Message, MessageTypeId,

MessageState) VALUES ({0},{1},'{2}',{3},{4})",

UserHelper.loginId, friendId, txtChat.Text.Trim(), 1, 0);

try

{

// 执行命令

SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open();

result = command.ExecuteNonQuery();

}

catch (Exception ex)

{

Console.WriteLine(ex.Message);

}

finally

{

DBHelper.connection.Close();

}

if (result != 1)

{

MessageBox.Show("服务器出现意外错误!", "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

txtChat.Text = ""; // 输入消息清空

this.Close();

}

}

/// <summary>

/// 读取所有的未读消息,显示在窗体中

/// </summary>

private void ShowMessage()

{

string messageIdsString = ""; // 消息的Id组成的字符串

string message; // 消息内容

string messageTime; // 消息发出的时间

// 读取消息的SQL语句

string sql = string.Format(

"SELECT Id, Message,MessageTime From Messages WHERE FromUserId={0} AND ToUserId={1} AND MessageTypeId=1 AND MessageState=0",

friendId,UserHelper.loginId);

try

{

SqlCommand command = new SqlCommand(sql, DBHelper.connection);

DBHelper.connection.Open();

SqlDataReader reader = command.ExecuteReader();

// 循环将消息添加到窗体上

while (reader.Read())

{

messageIdsString += Convert.ToString(reader["Id"]) + "_";

message = Convert.ToString(reader["Message"]);

messageTime = Convert.ToDateTime(reader["MessageTime"]).ToString(); // 转换为日期类型,告诉学员

lblMessages.Text += string.Format("\n{0} {1}\n

{2}",nickName,messageTime,message);

}

reader.Close();

}

catch (Exception ex)

{

Console.WriteLine(ex.Message);

}

finally

{

DBHelper.connection.Close();

}

// 把显示出的消息置为已读

if (messageIdsString.Length > 1)

{

messageIdsString.Remove(messageIdsString.Length - 1);

SetMessageRead(messageIdsString, '_');

}{qq宣传源码}.

}

/// <summary>

/// 把显示出的消息置为已读

/// </summary>

private void SetMessageRead(string messageIdsString, char separator)

{

string[] messageIds = messageIdsString.Split(separator); // 分割出每个消息Id string sql = "Update Messages SET MessageState=1 WHERE Id="; // 更新状态的SQL语句的固定部分

string updateSql; // 执行的SQL语句

try

{

qq宣传源码篇三

(山寨版QQ)源代码

关于山寨QQ的java的源代码

Java是一种可以撰写跨平台应用软件的面向对象的程序设计语言,是由Sun Microsystems公司于1995年5月推出的Java程序设计语言和Java平台(即JavaSE, JavaEE, JavaME)的总称。Java 技术具有卓越的通用性、高效性、平台移植性和安全性,广泛应用于个人PC、数据中心、游戏控制台、科学超级计算机、移动电话和互联网,同时拥有全球最大的开发者专业社群。在全球云计算和移动互联网的产业环境下,Java更具备了显著优势和广阔前景。

文库里没有关于山寨QQ的java的源代码,只能看了视频整理自己写了,特免费分享。

文档说明:根据java教学视频《韩顺平.循序渐进学.java.从入门到精通》(第87~94讲)整理得源相关代码。代码调试无误,下载后调试有误的可评论留言联系。image中图片附录在源代码后面。

工程文件夹:

(源代码)

qq宣传源码篇四

QQ登录源码

'这个模块除了MD5加密部分是网上找来的,其余部分都是本人独立完成

'其实也很简单,就是MD5+BASE64,要问16还是32的MD5,其实是32的,只不过加密后的

'32位长的字符串要把他看成另一个字符串的HEX,然后将那个字符串用BASE64编码下 '关键是VB里那个字符串会显示为"???",就是乱码

'--------------这是模块1的-------MD5加密-------------------------------------------------------------------------

Private m_lOnBits(30)

Private m_l2Power(30)

Private Const BITS_TO_A_BYTE = 8

Private Const BYTES_TO_A_WORD = 4

Private Const BITS_TO_A_WORD = 32

Function Hex2Bin(HexStr1 As String)

Select Case UCase(HexStr1)

'16进制转换二进制

Case "0"

q1 = "0000"

Case "1"

q1 = "0001"

Case "2"

q1 = "0010"

Case "3"

q1 = "0011"

Case "4"

q1 = "0100"

Case "5"

q1 = "0101"

Case "6"

q1 = "0110"

Case "7"

q1 = "0111"

Case "8"

q1 = "1000"

Case "9"

q1 = "1001"

Case "A"

q1 = "1010"

Case "B"

q1 = "1011"

Case "C"

q1 = "1100"

Case "D"

q1 = "1101"

q1 = "1110"{qq宣传源码}.

Case "F"

q1 = "1111"

End Select

Hex2Bin = q1

End Function

Function Hex2Bin1(HexStr2 As String)

'分断{qq宣传源码}.

q1 = Hex2Bin(Mid(HexStr2, 1, 1))

q2 = Hex2Bin(Mid(HexStr2, 2, 1))

q3 = Hex2Bin(Mid(HexStr2, 3, 1))

q4 = Hex2Bin(Mid(HexStr2, 4, 1))

q5 = Hex2Bin(Mid(HexStr2, 5, 1))

q6 = Hex2Bin(Mid(HexStr2, 6, 1))

q7 = Hex2Bin(Mid(HexStr2, 7, 1))

q8 = Hex2Bin(Mid(HexStr2, 8, 1))

q9 = Hex2Bin(Mid(HexStr2, 9, 1))

q10 = Hex2Bin(Mid(HexStr2, 10, 1))

q11 = Hex2Bin(Mid(HexStr2, 11, 1))

q12 = Hex2Bin(Mid(HexStr2, 12, 1))

Hex2Bin1 = q1 & q2 & q3 & q4 & q5 & q6 & q7 & q8 & q9 & q10 & q11 & q12

End Function

Function Bin324(BinCode1 As String)

'填充

q1 = Mid(BinCode1, 1, 6)

q2 = Mid(BinCode1, 7, 6)

q3 = Mid(BinCode1, 13, 6)

q4 = Mid(BinCode1, 19, 6)

q5 = Mid(BinCode1, 25, 6)

q6 = Mid(BinCode1, 31, 6)

q7 = Mid(BinCode1, 37, 6)

q8 = Mid(BinCode1, 43, 6)

Bin324 = "00" & q1 & "00" & q2 & "00" & q3 & "00" & q4 & "00" & q5 & "00" & q6 & "00" & q7 & "00" & q8

End Function

Function Bin2Hex(BinCode2 As String)

'二进制转换为16进制(BASE64一部分)

Select Case UCase(BinCode2)

Case "0000"

Case "0001"

q1 = "1"

Case "0010"

q1 = "2"

Case "0011"

q1 = "3"

Case "0100"

q1 = "4"

Case "0101"

q1 = "5"

Case "0110"

q1 = "6"

Case "0111"

q1 = "7"

{qq宣传源码}.

Case "1000"

q1 = "8"

Case "1001"

q1 = "9"

Case "1010"

q1 = "A"

Case "1011"

q1 = "B"

Case "1100"

q1 = "C"

Case "1101"

q1 = "D"

Case "1110"

q1 = "E"

Case "1111"

q1 = "F"

End Select

Bin2Hex = q1

End Function

Function Bin2Hex2(BinCode As String)

q1 = Bin2Hex(Mid(BinCode, 1, 4))

q2 = Bin2Hex(Mid(BinCode, 5, 4))

q3 = Bin2Hex(Mid(BinCode, 9, 4))

q4 = Bin2Hex(Mid(BinCode, 13, 4))

Bin2Hex2 = q1 & q2 & q3 & q4

End Function

Function Bin2Hex3(BinCode3 As String)

q1 = Bin2Hex2(Mid(BinCode3, 1, 16))

q2 = Bin2Hex2(Mid(BinCode3, 17, 16))

q3 = Bin2Hex2(Mid(BinCode3, 33, 16))

q4 = Bin2Hex2(Mid(BinCode3, 49, 16))

Bin2Hex3 = q1 & q2 & q3 & q4

End Function

Function HexBase64(HexString As String)

HexBase64 = HexBase64_2(Bin2Hex3(Bin324(Hex2Bin1(HexString)))) End Function

Function HexBase64_1(HexString As String)

Select Case HexString

Case "00"

q1 = "A"

Case "01"

q1 = "B"

Case "02"

q1 = "C"

Case "03"

q1 = "D"{qq宣传源码}.

Case "04"

q1 = "E"

Case "05"

q1 = "F"

Case "06"

q1 = "G"

Case "07"

q1 = "H"

Case "08"

q1 = "I"

Case "09"

q1 = "J"

Case "0A"

q1 = "K"

Case "0B"

q1 = "L"

Case "0C" q1 = "M" Case "0D" q1 = "N" Case "0E" q1 = "O" Case "0F" q1 = "P" Case "10" q1 = "Q" Case "11" q1 = "R" Case "12" q1 = "S" Case "13" q1 = "T" Case "14" q1 = "U" Case "15" q1 = "V" Case "16" q1 = "W" Case "17" q1 = "X" Case "18" q1 = "Y" Case "19" q1 = "Z" Case "1A" q1 = "a" Case "1B" q1 = "b" Case "1C" q1 = "c" Case "1D" q1 = "d" Case "1E" q1 = "e" Case "1F" q1 = "f" Case "20" q1 = "g" Case "21" q1 = "h"

qq宣传源码篇五

QQ源代码分析

QQ源代码分析

(5664版)

一、源文件分析

1、应用程序框架类:KQQMIDlet.java

定义了一个http地址:公共变量:

public static KQQMIDlet instance = null;

public static Display display = null;

public static Runtime runtime = null;

public int gaugeState;

public String strUserID;

public String strPasswd;

public static String url = "

public static MainMenu mainMenu;

public static HttpPoster httpPoster;

public static FriendRecord friendRecord;

public static FriendList friendList;

public static GetMsgDlg getMsgDlg;

public static SendMsgDlg sendMsgDlg;

public static AddFriend addFriend;

public static Finger finger;

public static AckSvrMsg ackSvrMsg;

public static MainForm mainForm;

public static BlackList blackList;

public static MultiLan sysString;

public static HistoryMsg historyMsg;

public boolean isWaitLogin;

公共方法:

public void init()

public void startApp() 应用程序开始函数;当应用程序开始运行时、应用程序暂停后再继续时被调用;根据不同的情况进行不同的操作:

当应用程序是暂停后再继续则显示暂停前的屏幕,当应用程序是登录时并且不是等待登录则显示mainForm;

public void pauseApp(); //程序暂停时被调用,当被调用时,第一时间设置好暂停标志isPause;然后判断是不是等待登录时的状态,若是则置等待登录标志,若不是则置dispPause变量; public void destroyApp(boolean flag); //仅是一接口函数,进作任何处理;

public void quitApp();//当程序退出时被调用,首先停止系统时钟,然后停止HTTP发送; public void onLoadEnd()

public void startTimer(int i)

public void stopTimer()

public void OnTimer()

public void onNetError(boolean flag)

public void showMessage(String s, String s1, CommandListener commandlistener, Command command, Command command1)

public void playAlert()

public Displayable getCurrent()

public void showAlert(String s, String s1, Displayable displayable)

public void showHelpForm()

public void commandAction(Command command, Displayable displayable)

public void receiveHttpResponse(String s)

public void handleHttpError(String s)

public void itemStateChanged(Item item)

2、MD5算法类:MD5.java

此文件中定义了一个MD5类,该类实现对一个字符串进行MD5加密,提供如下公共变量和方法:

公共变量:

public String digestHexStr; //此变量中存放了将输入串进行MD5运算后的128位MD5码的ASCII码。

公共方法:

public String getMD5ofStr(String s); //对字符串s进行MD5运算,返回该字符串的MD5字符串,在调用该函数前需要进行初始化操作,即调用其构造函数;

public MD5(); //构造函数,对变量进行实始化;

public static long b2iu(byte byte0); //将一字节的有符号数转换成一无符号的long型值; public static String byteHEX(byte byte0); //将一字节转换成该字节的ASCII字符串;

public static String toMD5(String s); //对字符串s进行MD5运算;返回该串的MD5字符串;

3、Http接口类:HttpPosterListener.java

此文件中仅定义了两个接口:

public abstract void receiveHttpResponse(String s);

public abstract void handleHttpError(String s);

4、全屏显示图片类:FullScreen.java

此类主要功能是将一副图片显示到屏幕上,是全屏显示,在此类中定义了两个方法: public FullScreen(Image image); //构造函数,初始化图片变量;

public void paint(Graphics g); //显示图片操作;从0,0处开始显示图片,图片水平靠左,垂直靠上;

图片位置:

HCENTER 水平居中,值为1;

VCENTER 垂直居中,值为2;

LEFT 左齐,值为4;

RIGHT 右齐,值为8;

TOP 上齐,值为16;

BOTTOM 下齐,值为32;

BASELINE 齐基线,值为64;

SOLID 值为0;

5、包工具类:PkgTools.java

公共方法:

public PkgTools()

public static String To2Str(int i)

public static Image createImage(String s); //通过输入一个png文件名s创建一个Image对象; public static void EmptyForm(Form form)

public static void EmptyList(List list)

public static String Encodecgi(String s); //编码函数:将字符串中的' '、'&'、','、'\r'、'\t'、'\n'、'%'、'='这些字符转换成形如%XX的形式,其中XX为上述字符的ASCII码的十六进制形式;

public static String Decodecgi(String s); //解码函数,将含有形如%XX的十六进制数据的字符串中的%XX转换成一个字符;返回转换后的字符串;

public static String GetParaVal(String s, String s1)

public static int GetMultiPara(String as[], String s)

public static byte[] Unicode2Byte(String s)

public static byte[] convertUnicode2UTF8Byte(String s)

public static void saveDB()

public static void loadDB()

public static void setUserInfo(String s, String s1)

public static void setOtherInfo(String s, String s1, BlackList blacklist)

public static String getUIN()

public static String getPassWord()

public static String getControl()

{qq宣传源码}.

public static void getBlackList(BlackList blacklist)

public static void loadFriendData()

public static void saveFriendData(Vector vector)

6、好友记录项目类:FriendRecordItem.java

此类主要描述了一个好友对像,根据好友的号码字符串来生成好友的一些相关信息。 公共变量:

public String strUserID; //好友号码的ASCII字符串;

相关文章
推荐内容
上一篇:noodle的谚语
下一篇:QQ发说说怎么发动态图片
Copyright 学习网 版权所有 All Rights Reserved