diff options
-rw-r--r-- | Protocols/SIP/Docs/langpack_sip.txt | 2 | ||||
-rw-r--r-- | Protocols/SIP/Docs/sip_changelog.txt | 6 | ||||
-rw-r--r-- | Protocols/SIP/Docs/sip_readme.txt | 25 | ||||
-rw-r--r-- | Protocols/SIP/Docs/sip_version.txt | 1 | ||||
-rw-r--r-- | Protocols/SIP/SIPProto.cpp | 19 | ||||
-rw-r--r-- | Protocols/SIP/build/google_code.rb | 191 | ||||
-rw-r--r-- | Protocols/SIP/build/rakefile | 223 | ||||
-rw-r--r-- | Protocols/SIP/build/zip.exe | bin | 0 -> 290816 bytes | |||
-rw-r--r-- | Protocols/SIP/sip.vcproj | 4 |
9 files changed, 462 insertions, 9 deletions
diff --git a/Protocols/SIP/Docs/langpack_sip.txt b/Protocols/SIP/Docs/langpack_sip.txt new file mode 100644 index 0000000..a1a0d7f --- /dev/null +++ b/Protocols/SIP/Docs/langpack_sip.txt @@ -0,0 +1,2 @@ +; SIP protocol
+; Author: Pescuma
diff --git a/Protocols/SIP/Docs/sip_changelog.txt b/Protocols/SIP/Docs/sip_changelog.txt new file mode 100644 index 0000000..a3557ef --- /dev/null +++ b/Protocols/SIP/Docs/sip_changelog.txt @@ -0,0 +1,6 @@ +SIP protocol
+
+Changelog:
+
+. 0.1.0.0
+ + Initial version
\ No newline at end of file diff --git a/Protocols/SIP/Docs/sip_readme.txt b/Protocols/SIP/Docs/sip_readme.txt new file mode 100644 index 0000000..d5887fd --- /dev/null +++ b/Protocols/SIP/Docs/sip_readme.txt @@ -0,0 +1,25 @@ +SIP protocol
+------------
+
+CAUTION: THIS IS A ALPHA STAGE PLUGIN. IT CAN DO VERY BAD THINGS. USE AT YOUR OWN RISK.
+
+This is a SIP/SIMPLE protocol based on pjsip lib.
+
+Currently it allows to make/receive calls and im messages. All the GUI is handled by Voice Service plugin.
+
+WARNING: You can create only one instance of the protocol. If you create the second one miranda will crash and keep crashing at each startup. I'll fix it soon
+
+
+Known bugs:
+- When you login, you will only show online the contacts that already are online (contacts that came online after that will stay offline)
+
+
+Todo:
+- More than one instance
+- Protocol icons
+- Use netlib to send/receive packages?
+- Ask for new password at first login if "Save password" is not checked
+- Compile with VC6
+
+
+To report bugs/make suggestions, go to the forum thread: http://forums.miranda-im.org/showthread.php?p=
\ No newline at end of file diff --git a/Protocols/SIP/Docs/sip_version.txt b/Protocols/SIP/Docs/sip_version.txt new file mode 100644 index 0000000..591f6e1 --- /dev/null +++ b/Protocols/SIP/Docs/sip_version.txt @@ -0,0 +1 @@ +SIP protocol 0.1.0.0
\ No newline at end of file diff --git a/Protocols/SIP/SIPProto.cpp b/Protocols/SIP/SIPProto.cpp index c114e2c..fb2559c 100644 --- a/Protocols/SIP/SIPProto.cpp +++ b/Protocols/SIP/SIPProto.cpp @@ -98,12 +98,7 @@ public: return tchar;
}
- TCHAR operator[](int pos) const
- {
- return tchar[pos];
- }
-
- TCHAR & operator[](int pos)
+ const TCHAR & operator[](int pos) const
{
return tchar[pos];
}
@@ -113,6 +108,14 @@ private: };
+static pj_str_t pj_str(const char *str)
+{
+ pj_str_t ret;
+ pj_cstr(&ret, str);
+ return ret;
+}
+
+
static char * mir_pjstrdup(const pj_str_t *from)
{
char *ret = (char *) mir_alloc(from->slen + 1);
@@ -637,6 +640,7 @@ int SIPProto::Connect() pjsua_config cfg;
pjsua_config_default(&cfg);
+ cfg.use_srtp = PJMEDIA_SRTP_OPTIONAL;
cfg.cb.on_incoming_call = &static_on_incoming_call;
cfg.cb.on_call_media_state = &static_on_call_media_state;
cfg.cb.on_call_state = &static_on_call_state;
@@ -717,6 +721,7 @@ int SIPProto::Connect() pjsua_acc_config_default(&cfg);
cfg.user_data = this;
cfg.transport_id = transport_id;
+ cfg.use_srtp = PJMEDIA_SRTP_OPTIONAL;
BuildURI(tmp, MAX_REGS(tmp), opts.username, opts.domain);
TcharToSip id(tmp);
@@ -1245,7 +1250,7 @@ void SIPProto::on_incoming_call(pjsua_call_id call_id) name[0] = 0;
if (remote_info[0] == _T('"'))
{
- TCHAR *other = _tcsstr(&remote_info[1], _T("\" <"));
+ const TCHAR *other = _tcsstr(&remote_info[1], _T("\" <"));
if (other != NULL)
lstrcpyn(name, &remote_info[1], min(MAX_REGS(name), other - remote_info));
}
diff --git a/Protocols/SIP/build/google_code.rb b/Protocols/SIP/build/google_code.rb new file mode 100644 index 0000000..1c44900 --- /dev/null +++ b/Protocols/SIP/build/google_code.rb @@ -0,0 +1,191 @@ +require 'mechanize' + +class GoogleCode + FEATURED = "Featured" + DEPRECATED = "Deprecated" + + def initialize(project, username, password) + @browser = WWW::Mechanize.new + @project = project + + page = @browser.get(build_url) + + page = @browser.click page.link_with(:text => 'Sign in') + + form = page.forms.find_all { |form| \ + form.action == 'https://www.google.com/accounts/ServiceLoginAuth?service=code' \ + && form.has_field?("Email") \ + && form.has_field?("Passwd") }[0] + + raise "Could not talk to googlecode. Have they changed the pages layout?" unless form + + form.Email = username + form.Passwd = password + + page = form.submit + + raise 'GoogleCode: Invalid username/password' unless page.forms.length == 0 + end + + def all_files + get_files("downloads/list?can=1") + end + + def current_files + get_files("downloads/list?can=2") + end + + def featured_files + get_files("downloads/list?can=3") + end + + def deprecated_files + get_files("downloads/list?can=4") + end + + def fetch(filename) + page = @browser.get(build_url("downloads/detail?name=#{filename}")) + + form = page.form_with(:action => "update.do?name=#{filename}") + raise "Could not talk to googlecode. Have they changed the pages layout?" unless form + + file = Download.new filename + file.description = form.summary + file.labels = [] + form.fields.each { |f| file.labels << f.value if f.name == 'label' && f.value.length > 0 } + + file + end + + def update(file) + page = @browser.get(build_url("downloads/detail?name=#{file.filename}")) + + form = page.form_with(:action => "update.do?name=#{file.filename}") + raise "Could not talk to googlecode. Have they changed the pages layout?" unless form + + form.summary = file.description + + pos = 0 + form.fields.each do |f| + if f.name == 'label' + f.value = file.labels[pos] || '' + pos = pos + 1 + end + end + + form.submit # TODO Validate result + end + + def upload(file) + raise 'filename can\'t be empty' unless (file.filename || '').strip.length > 0 + raise 'description can\'t be empty' unless (file.description || '').strip.length > 0 + raise 'local_file can\'t be empty' unless (file.local_file || '').strip.length > 0 + + local_file = File.expand_path(file.local_file) + raise 'Local file could not be read' unless File.exist?(local_file) + raise 'Filename should be equal to local filename' unless File.basename(local_file) == file.filename + + page = @browser.get(build_url('downloads/entry')) + + form = page.form_with(:action => "http://uploads.code.google.com/upload/#{@project}") + raise "Could not talk to googlecode. Have they changed the pages layout?" unless form + + form.summary = file.description.strip + + pos = 0 + form.fields.each do |f| + if f.name == 'label' + f.value = (file.labels[pos] || '').strip + pos = pos + 1 + end + end + + form.file_uploads.first.file_name = local_file + + page = form.submit + + form = page.form_with(:action => "http://uploads.code.google.com/upload/#{@project}") + raise "Error uploading file #{file}" if form + + end + + class Download + attr_accessor :description, :labels, :local_file + attr_reader :filename + + def initialize(filename, fetcher = nil) + @filename = filename.strip + raise 'filename can\'t be empty' unless @filename + + @description = '' + @labels = [] + @fetcher = fetcher + end + + def description + fetch + return @description + end + + def labels + fetch + return @labels + end + + def to_s + fetch + ret = @filename + ret += ' : ' + @description if @description + ret += ' [' + @labels.join(', ') + ']' if @labels.length > 0 + end + + def <=>(other) + return @filename.casecmp(other.filename) + end + + private + + def fetch + return unless @fetcher + + tmp = @fetcher.fetch @filename + + @description = tmp.description + @labels = tmp.labels + + @fetcher = nil + end + + end + + + private + + def build_url(suffix = '') + if suffix == '' + return "http://code.google.com/p/#{@project}" + elsif suffix[0] == '/' + "http://code.google.com/p/#{@project}#{suffix}" + else + "http://code.google.com/p/#{@project}/#{suffix}" + end + end + + def get_files(url) + page = @browser.get(build_url(url)) + + start = "http://#{@project}.googlecode.com/files/" + + ret = [] + page.links.each do |link| + id = link.href + if id.length > start.length && id.slice(0, start.length) == start + id = id.slice(start.length, id.length - start.length) + ret << Download.new(id, self) + end + end + + return ret + end + +end diff --git a/Protocols/SIP/build/rakefile b/Protocols/SIP/build/rakefile new file mode 100644 index 0000000..78a6c05 --- /dev/null +++ b/Protocols/SIP/build/rakefile @@ -0,0 +1,223 @@ +require 'rake'
+require 'fileutils'
+require 'rake/clean'
+require 'google_code'
+
+PROJECT="sip"
+
+SRC_DIR=File.expand_path("..")
+DOCS_DIR=File.expand_path("../Docs")
+VERSION_FILE="#{DOCS_DIR}/#{PROJECT}_version.txt"
+
+TYPES=[ 'ansi', 'unicode' ]
+
+SETUP_VC='C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat'
+VC="devenv"
+
+version=nil
+
+def cp_relative(file, base, target)
+ file = File.expand_path(file)
+ base = File.expand_path(base)
+ raise "Wrong file/base : #{file} / #base" unless file.slice(0, base.length) == base
+
+ relative = file.slice(base.length, file.length - base.length)
+ target = File.expand_path(File.join(target, relative))
+ target_dir = File.dirname(target)
+
+ makedirs target_dir unless File.exists?(target_dir)
+ cp file, target
+end
+
+
+task :get_version do
+ File.open(VERSION_FILE, "r") do |file|
+ while (line = file.gets)
+ version = (line.match(/\d+\.\d+\.\d+\.\d+/) || [])[0]
+ break if version
+ end
+ end
+ raise "Could not read version file" unless VERSION
+ puts "Building version #{version} of #{PROJECT}"
+end
+
+
+# Build ##############################################################################
+
+SOLUTION="#{PROJECT}.sln"
+CONFIG=[ "Release", "Unicode Release" ]
+BUILD_RESULT_DIR=[ "../Release", "../Unicode_Release" ]
+DLL=[ "../../../bin/Release/Plugins/#{PROJECT}.dll", "../../../bin/Release Unicode/Plugins/#{PROJECT}W.dll" ]
+PDB=[ "#{BUILD_RESULT_DIR[0]}/#{PROJECT}.pdb", "#{BUILD_RESULT_DIR[1]}/#{PROJECT}W.pdb" ]
+
+(0..1).each do |i|
+ type = TYPES[i]
+
+ build = "build_#{type}".to_s
+
+ desc "Build #{type} project"
+ task build do
+ chdir(SRC_DIR) do
+ sh "#{VC} #{SOLUTION} /Build \"#{CONFIG[i]}\"" do |ok, status|
+ ok or fail "Failed to compile #{type} dll (#{status.exitstatus})"
+ end
+ end
+ end
+ task :build => build
+
+ CLEAN.include(File.join(BUILD_RESULT_DIR[i], '/**/*'))
+ CLOBBER.include(DLL[i])
+end
+
+
+# Source zip #########################################################################
+
+SRC_FILES = FileList[ \
+ "#{SRC_DIR}/*.cpp", \
+ "#{SRC_DIR}/*.h", \
+ "#{SRC_DIR}/*.rc", \
+ "#{SRC_DIR}/*.sln", \
+ "#{SRC_DIR}/*.vcproj", \
+ "#{SRC_DIR}/*.dsp", \
+ "#{SRC_DIR}/*.dsw", \
+ "#{SRC_DIR}/lib/**/*.h", \
+ "#{SRC_DIR}/sdk/**/*.h" \
+]
+SRC_ZIP="#{PROJECT}_src"
+SRC_ZIP_FOLDER='zip_src'
+
+task :clean_package_src do
+ rmtree SRC_ZIP_FOLDER
+end
+task :clean => :clean_package_src
+
+desc "Create source package"
+task :package_src => :get_version do
+ rmtree SRC_ZIP_FOLDER
+ mkdir SRC_ZIP_FOLDER
+
+ SRC_FILES.each do |file|
+ cp_relative(file, SRC_DIR, SRC_ZIP_FOLDER)
+ end
+
+ zip = "#{SRC_ZIP}.#{version}.zip"
+ rm zip, :force => true
+ chdir(SRC_ZIP_FOLDER) do
+ sh "../zip -r -q ../#{zip} *"
+ end
+
+ rmtree SRC_ZIP_FOLDER
+end
+task :package => :package_src
+
+CLOBBER.include("#{SRC_ZIP}.*.zip")
+
+
+
+# Dll zips ###########################################################################
+
+ZIP_FOLDERS=['zip_ansi', 'zip_unicode']
+ZIPS=[ "#{PROJECT}", "#{PROJECT}W" ]
+
+(0..1).each do |i|
+ type = TYPES[i]
+
+ clean = "clean_package_#{type}".to_s
+ package = "package_#{type}".to_s
+
+ task clean do
+ rmtree ZIP_FOLDERS[i]
+ rmtree ZIP_FOLDERS[i] + '_pdb'
+ end
+ task :clean => clean
+
+ desc "Create #{type} package"
+ task package => [ clean, :get_version, "build_#{type}".to_s ] do
+ rmtree ZIP_FOLDERS[i]
+ mkdir ZIP_FOLDERS[i]
+
+ target_dir = File.join(ZIP_FOLDERS[i], 'Docs')
+ docs = FileList["#{DOCS_DIR}/*"]
+ docs.exclude(VERSION_FILE)
+ docs.each do |file|
+ cp_relative(file, DOCS_DIR, target_dir)
+ end
+
+ target_dir = File.join(ZIP_FOLDERS[i], 'Plugins')
+ makedirs target_dir
+ cp DLL[i], target_dir
+
+ zip = "#{ZIPS[i]}.#{version}.zip"
+ rm zip, :force => true
+ chdir(ZIP_FOLDERS[i]) do
+ sh "../zip -r -q ../#{zip} *"
+ end
+ rmtree ZIP_FOLDERS[i]
+
+ rmtree ZIP_FOLDERS[i] + '_pdb'
+ target_dir = ZIP_FOLDERS[i] + '_pdb/Plugins'
+ makedirs target_dir
+ cp PDB[i], target_dir
+ chdir(ZIP_FOLDERS[i] + '_pdb') do
+ sh "../zip -r -q ../#{ZIPS[i]}.pdb.#{version}.zip *"
+ end
+ rmtree ZIP_FOLDERS[i] + '_pdb'
+ end
+ task :package => package
+
+ CLOBBER.include("#{ZIPS[i]}.pdb.*.zip")
+ CLOBBER.include("#{ZIPS[i]}.*.zip")
+end
+
+
+# Rebuild ############################################################################
+
+desc "Rebuild all #{PROJECT} versions"
+task :rebuild => [ :clobber, :build ]
+
+desc "Build all #{PROJECT} versions"
+task :build
+
+
+# Upload #############################################################################
+
+desc "Rebuild and upload files"
+task :upload => [ :rebuild, :pack ]
+
+
+def empty?(str)
+ return true unless str
+ return str.strip.length > 0
+end
+
+desc "Upload to googlecode"
+task :upload_googlecode => [ :build, :pack ] do
+ project = nil
+ username = nil
+ password = nil
+
+ if File.exists?("googlecode.passwd")
+ File.open("googlecode.passwd", "r") do |file|
+ project,username,password = file.gets.split(':')
+ end
+ end
+
+ if empty?(project)
+ puts "Project name: "
+ project = gets.chomp
+ end
+ if empty?(username)
+ puts "Username: "
+ username = gets.chomp
+ end
+ if empty?(password)
+ puts "Password: "
+ password = gets.chomp
+ end
+
+ raise "Invalid googlecode data" if empty?(project) || empty?(username) || empty?(password)
+
+ puts project + ' ' + username + ' ' + password
+
+end
+task :upload => :upload_googlecode
\ No newline at end of file diff --git a/Protocols/SIP/build/zip.exe b/Protocols/SIP/build/zip.exe Binary files differnew file mode 100644 index 0000000..65de183 --- /dev/null +++ b/Protocols/SIP/build/zip.exe diff --git a/Protocols/SIP/sip.vcproj b/Protocols/SIP/sip.vcproj index d27fd98..1d867aa 100644 --- a/Protocols/SIP/sip.vcproj +++ b/Protocols/SIP/sip.vcproj @@ -50,7 +50,7 @@ Optimization="2"
InlineFunctionExpansion="0"
AdditionalIncludeDirectories="../../include;sdk;lib\pjsip\pjlib\include;"lib\pjsip\pjlib-util\include";lib\pjsip\pjmedia\include;lib\pjsip\pjsip\include;lib\pjsip\pjnath\include"
- PreprocessorDefinitions="PJ_WIN32=1;WIN32;W32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS"
+ PreprocessorDefinitions="PJ_WIN32=1;WIN32;W32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
@@ -350,7 +350,7 @@ Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../include;sdk;lib\pjsip\pjlib\include;"lib\pjsip\pjlib-util\include";lib\pjsip\pjmedia\include;lib\pjsip\pjsip\include;lib\pjsip\pjnath\include"
- PreprocessorDefinitions="PJ_WIN32=1;WIN32;W32;_DEBUG;_WINDOWS;UNICODE;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS"
+ PreprocessorDefinitions="PJ_WIN32=1;WIN32;W32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\Unicode_Debug/sip.pch"
AssemblerListingLocation=".\Unicode_Debug/"
|