using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Messenger;
using System.Windows.Forms;
public class Konusma : IMessengerAddIn
{
private MessengerClient _client = null;
string[] ary = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
"l", "m", "n", "o", "p", "r", "s", "t", "u", "v", "y", "z" };
public string encrypt(string str)
{
int i = 0; int j = 0; string str1 = "";
for (i = 0; i < str.Length; i++)
{
for (j = 0; j < 23; j++)
{
if (str.Substring(i, 1) == ary[j])
str1 = str1 + ary[(j + 3 + 23) % 23];
}
}
return str1;
}
public string decrypt(string str)
{
int i = 0; int j = 0; string str1 = "";
for (i = 0; i < str.Length; i++)
{
for (j = 0; j < 23; j++)
{
if (str.Substring(i, 1) == ary[j])
str1 = str1 + ary[(j - 3 + 23) % 23];
}
}
return str1;
}
public void Initialize(MessengerClient messenger)
{
Client = messenger;
initAddin();
}
public MessengerClient Client
{
get
{
return _client;
}
private set
{
_client = value;
}
}
private void initAddin()
{
Client.AddInProperties.Status = UserStatus.Online;
Client.IncomingTextMessage += new
EventHandler<IncomingTextMessageEventArgs>(Client_IncomingTextMessage);
Client.OutgoingTextMessage += new
EventHandler<OutgoingTextMessageEventArgs>(Client_OutgoingTextMessage);
}
void Client_OutgoingTextMessage(object sender,
OutgoingTextMessageEventArgs e)
{
//string cipherText = encrypt(e.TextMessage);
//e.Cancel = true;
//MessageBox.Show("Cipher text length(" + cipherText + ") is: " +
cipherText.Length);
//Client.SendTextMessage(cipherText, e.UserTo);
}
void Client_IncomingTextMessage(object sender,
IncomingTextMessageEventArgs e)
{
string plainText = decrypt(e.TextMessage);
MessageBox.Show("Plain text length(" + plainText + ") is: " +
plainText.Length);
MessageBox.Show(plainText);
}
}
****************************************
Hi,
Our problem is that if two messenger client (e.g. one is called Bob and the
other is called Jane) (Both of them use dll file as shown above) and if Bob
writes sth obviously dll takes it and encrypt this according to encrypt
function , but Jane gets encrypted message but Incoming_Message function is
not working. So Jane just gets encrypted message. Our aim is as specified in
the source code of dll file. But I wanna say it again . If Bob writes sth,
Bob's dll will encrypt its writing, and Jane gets this encrypted string and
it's showed at the coming text box in the Jane's messenger and then Jane's
dll gets this and decrypts this string then result is shown in the message
box to Jane. But this two dll can't run at simultaneously.We added same dll
to the two messenger.
p.s. You can download our project in this adress
http://rs73.rapidshare.com/files/80058220/Peltek.rar