2006-05-17 13:48:37 +00:00
|
|
|
#include "SecondLife.h"
|
|
|
|
|
#include <stdio.h>
|
2006-05-27 02:42:28 +00:00
|
|
|
#include <signal.h>
|
2006-05-17 13:48:37 +00:00
|
|
|
|
2006-05-25 22:20:43 +00:00
|
|
|
SecondLife* client;
|
|
|
|
|
|
|
|
|
|
void loginHandler(loginParameters login)
|
|
|
|
|
{
|
|
|
|
|
if (login.reason.length()) {
|
2006-05-27 02:42:28 +00:00
|
|
|
printf("test_app: Login failed\n");
|
2006-05-25 22:20:43 +00:00
|
|
|
} else {
|
2006-06-01 08:09:12 +00:00
|
|
|
PacketPtr packetPtr = DirLandQuery(client->protocol(), false, true, SimpleLLUUID(1), true, 0,
|
|
|
|
|
client->agent_id(), client->session_id());
|
|
|
|
|
client->sendPacket(packetPtr);
|
2006-05-25 22:20:43 +00:00
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
|
client->tick();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-01 08:09:12 +00:00
|
|
|
/*void writePacket(std::string command, PacketPtr packet)
|
|
|
|
|
{
|
|
|
|
|
byte* data = packet->buffer();
|
|
|
|
|
size_t length = packet->length();
|
|
|
|
|
|
|
|
|
|
printf("Wrote packet to file\n");
|
|
|
|
|
|
|
|
|
|
FILE* file = fopen("dirlandreply.dat", "ab");
|
|
|
|
|
fwrite(data, length, 1, file);
|
|
|
|
|
fclose(file);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
void landPacket(std::string command, PacketPtr packet)
|
2006-05-27 02:42:28 +00:00
|
|
|
{
|
2006-06-01 08:09:12 +00:00
|
|
|
FieldList::iterator field;
|
|
|
|
|
BlockList::iterator block;
|
|
|
|
|
BlockList blocks = packet->getBlocks();
|
|
|
|
|
bool firstLand;
|
|
|
|
|
int area;
|
|
|
|
|
bool forSale;
|
|
|
|
|
byte* parcelID;
|
|
|
|
|
std::string name;
|
|
|
|
|
bool auction;
|
|
|
|
|
int salePrice;
|
|
|
|
|
|
|
|
|
|
for (block = blocks.begin(); block != blocks.end(); ++block) {
|
|
|
|
|
if ((*block)->name() == "QueryReplies") {
|
|
|
|
|
for (field = (*block)->fields.begin(); field != (*block)->fields.end(); ++field) {
|
|
|
|
|
if ((*field)->name() == "ReservedNewbie") {
|
|
|
|
|
firstLand = *(*field)->data;
|
|
|
|
|
} else if ((*field)->name() == "ActualArea") {
|
|
|
|
|
area = *(int*)(*field)->data;
|
|
|
|
|
} else if ((*field)->name() == "ForSale") {
|
|
|
|
|
forSale = *(*field)->data;
|
|
|
|
|
} else if ((*field)->name() == "ParcelID") {
|
|
|
|
|
parcelID = (*field)->data;
|
|
|
|
|
} else if ((*field)->name() == "Name") {
|
|
|
|
|
name = (char*)(*field)->data;
|
|
|
|
|
} else if ((*field)->name() == "Auction") {
|
|
|
|
|
auction = *(*field)->data;
|
|
|
|
|
} else if ((*field)->name() == "SalePrice") {
|
|
|
|
|
salePrice = *(int*)(*field)->data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::cout << name << " | Price: " << salePrice << " | Area: " << area << " | For Sale: "
|
|
|
|
|
<< forSale << " | Auction: " << auction << std::endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-05-27 02:42:28 +00:00
|
|
|
}
|
|
|
|
|
|
2006-06-01 08:09:12 +00:00
|
|
|
void receivedPacket(std::string command, PacketPtr packet)
|
2006-05-25 22:20:43 +00:00
|
|
|
{
|
2006-06-01 08:09:12 +00:00
|
|
|
/*byte* data = packet->buffer();
|
2006-05-25 22:20:43 +00:00
|
|
|
size_t length = packet->length();
|
|
|
|
|
|
2006-05-27 02:42:28 +00:00
|
|
|
if (!command.length()) {
|
2006-06-01 08:09:12 +00:00
|
|
|
printf("test_app: Received foreign datagram:\n");
|
2006-05-27 02:42:28 +00:00
|
|
|
|
|
|
|
|
for (size_t i = 0; i < length; i++) {
|
|
|
|
|
printf("%02x ", data[i]);
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
|
|
return;
|
2006-05-25 22:20:43 +00:00
|
|
|
}
|
2006-05-27 02:42:28 +00:00
|
|
|
|
|
|
|
|
printf("test_app: Received a %u byte %s datagram (%u)\n", length, command.c_str(), packet->sequence());
|
|
|
|
|
|
2006-06-01 08:09:12 +00:00
|
|
|
return;*/
|
2006-05-25 22:20:43 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-17 13:48:37 +00:00
|
|
|
int main()
|
2006-05-25 22:20:43 +00:00
|
|
|
{
|
|
|
|
|
client = new SecondLife();
|
|
|
|
|
|
2006-05-17 13:48:37 +00:00
|
|
|
if (client->loadKeywords("keywords.txt") == 0) {
|
2006-05-27 02:42:28 +00:00
|
|
|
printf("test_app: Loaded keyword file\n");
|
2006-05-17 13:48:37 +00:00
|
|
|
} else {
|
2006-05-27 02:42:28 +00:00
|
|
|
printf("test_app: Failed to load the keyword file\n");
|
2006-05-17 13:48:37 +00:00
|
|
|
|
|
|
|
|
delete client;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2006-05-27 02:42:28 +00:00
|
|
|
|
2006-05-17 13:48:37 +00:00
|
|
|
if (client->decryptCommFile("comm.dat", "output.txt") == 0) {
|
2006-05-27 02:42:28 +00:00
|
|
|
printf("test_app: Decrypted comm file\n");
|
2006-05-17 13:48:37 +00:00
|
|
|
} else {
|
2006-05-27 02:42:28 +00:00
|
|
|
printf("test_app: Failed to decrypt the comm file\n");
|
2006-05-17 13:48:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (client->buildProtocolMap("output.txt") == 0) {
|
2006-05-27 02:42:28 +00:00
|
|
|
printf("test_app: Built protocol map\n");
|
2006-05-17 13:48:37 +00:00
|
|
|
} else {
|
2006-05-27 02:42:28 +00:00
|
|
|
printf("test_app: Failed to build the protocol map\n");
|
2006-05-17 13:48:37 +00:00
|
|
|
|
|
|
|
|
delete client;
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
2006-05-25 22:20:43 +00:00
|
|
|
|
2006-05-27 02:42:28 +00:00
|
|
|
//client->printMap();
|
2006-05-25 22:20:43 +00:00
|
|
|
|
2006-06-01 08:09:12 +00:00
|
|
|
client->registerCallback("DirLandReply", &landPacket);
|
2006-05-25 22:20:43 +00:00
|
|
|
client->registerCallback("Default", &receivedPacket);
|
2006-05-27 02:42:28 +00:00
|
|
|
|
2006-06-01 08:09:12 +00:00
|
|
|
client->login("Chelsea", "Cork", "grapefruit", "00:00:00:00:00:00", 1, 10, 1, 0, "Win", "0", "test_app",
|
2006-05-27 02:42:28 +00:00
|
|
|
"jhurliman@wsu.edu", loginHandler);
|
2006-05-25 22:20:43 +00:00
|
|
|
|
2006-05-17 13:48:37 +00:00
|
|
|
delete client;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|