summaryrefslogtreecommitdiff
path: root/protocols/AimOscar/file.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-18 21:52:06 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-18 21:52:06 +0000
commit47e5e82a35999401cc7676cd19a4b8b289a2024c (patch)
tree20449be9036d3d2503b49f4c2ba481be99261c66 /protocols/AimOscar/file.cpp
parentbb7bf61220abb44c385deabda02daed66e9e2389 (diff)
sync
git-svn-id: http://svn.miranda-ng.org/main/trunk@1030 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/AimOscar/file.cpp')
-rw-r--r--protocols/AimOscar/file.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/protocols/AimOscar/file.cpp b/protocols/AimOscar/file.cpp
index e1cba43c40..7af67727e8 100644
--- a/protocols/AimOscar/file.cpp
+++ b/protocols/AimOscar/file.cpp
@@ -1,6 +1,6 @@
/*
Plugin of Miranda IM for communicating with users of the AIM protocol.
-Copyright (c) 2008-2009 Boris Krasnovskiy
+Copyright (c) 2008-2012 Boris Krasnovskiy
Copyright (C) 2005-2006 Aaron Myles Landwehr
This program is free software; you can redistribute it and/or
@@ -496,23 +496,12 @@ file_transfer* ft_list_type::find_by_cookie(char* cookie, HANDLE hContact)
return NULL;
}
-file_transfer* ft_list_type::find_by_ip(unsigned long ip)
+file_transfer* ft_list_type::find_by_port(unsigned short port)
{
for (int i = getCount(); i--; )
{
file_transfer *ft = items[i];
- if (ft->accepted && ft->requester && (ft->local_ip == ip || ft->verified_ip == ip))
- return ft;
- }
- return NULL;
-}
-
-file_transfer* ft_list_type::find_suitable(void)
-{
- for (int i = getCount(); i--; )
- {
- file_transfer *ft = items[i];
- if (ft->accepted && ft->requester)
+ if (ft->requester && ft->local_port == port)
return ft;
}
return NULL;
@@ -561,6 +550,8 @@ file_transfer::file_transfer(HANDLE hCont, char* nick, char* cookie)
file_transfer::~file_transfer()
{
+ stop_listen();
+
mir_free(file);
mir_free(message);
mir_free(sn);
@@ -577,3 +568,25 @@ file_transfer::~file_transfer()
}
CloseHandle(hResumeEvent);
}
+
+void file_transfer::listen(CAimProto* ppro)
+{
+ if (hDirectBoundPort) return;
+
+ NETLIBBIND nlb = {0};
+ nlb.cbSize = sizeof(nlb);
+ nlb.pfnNewConnectionV2 = aim_direct_connection_initiated;
+ nlb.pExtra = ppro;
+ hDirectBoundPort = (HANDLE)CallService(MS_NETLIB_BINDPORT, (WPARAM)ppro->hNetlibPeer, (LPARAM)&nlb);
+ local_port = hDirectBoundPort ? nlb.wPort : 0;
+}
+
+void file_transfer::stop_listen(void)
+{
+ if (hDirectBoundPort)
+ {
+ Netlib_CloseHandle(hDirectBoundPort);
+ hDirectBoundPort = NULL;
+ local_port = 0;
+ }
+}