Integrando Skype em aplicações Delphi

Post on 11-Jun-2015

9.859 views 7 download

description

Skype é um dos meios mais utilizados no mundo para conectar pessoas, milhões de usuários utilizam esta ferramenta diariamente, assim sendo porque não integrar nossas aplicações ao Skype? Através do Skype API podemos efetuar chamadas, receber, encaminhar, criar vídeo conferência e muito mais, praticamente tudo está disponível através desta API. Nesta apresentação vamos aprender na prática como integrar nossas aplicações Delphi ao Skype e utilizar os componentes TMS Smooth Controls para criar interfaces ricas.

Transcript of Integrando Skype em aplicações Delphi

1

Integrando Skype em aplicações Delphi

Andreano Lanusse

Technical Lead Evangelist, Developer Relations

2

O que é Skype?

• P2P Internet Telephone – VOIP– Computador para Computador– Computador para Telefone (SkypeOut)– Telefone para Computador (Skypein)

• P2P Instant Messenger– Tópics– Históricos

• P2P Application Framework

3

O que é Skype?

• Mais de 500 milhões de downloads• Mais de 130 milhões de usuários ativos• 4 a 8 milhões de usuários simultâneos• 250000 novos usuários por dia

4

O quão amigável é o Skype

• Delphi amigável– Windows Client escrito em Delphi– Usa Indy para as comunicações que não são P2P– SDK Tools escrito em Delphi– Algumas documentação e interfaces escritas em pascal

• Exemplos– Delphi– C++– C#– VB– Phyton

5

Desenvolvendo para Skype

• Skype API– Método original de integração– Usa Windows Message– Muito flexível

• Skype4COM / Skype4Java– Easy Object Wrappers– Menos flexível

• Skype Extras– Plug-in Framework

6

O que você precisa para usar Skype API

• Instalação– Skype: http://www.skype.com– Nenhum outro arquivo necessário

• Documentação– API – https://developer.skype.com/Docs/ApiDoc– Dev Notes - https://developer.skype.com/Docs/DevNotes

• Este apresentação– Vamos focar no Skype API e Skype4COM

7

Usando Skype API

• Conectando ao Skype– Registrar ‘SkypeControlAPIDiscover’ windows message– Registrar ‘SkypeControlAPIAttach’ windows message– Broadcast ‘SkypeControlAPIDiscover’ windows message– Skype responde com um ‘SkypeControlAPIAttach’ message– Identificao o Protocolo de referência

procedure TSkypeAPI.Connect;begin if IsSkypeInstalled then begin FSkypeAPIDiscover := RegisterWindowMessage('SkypeControlAPIDiscover'); FSkypeAPIAttach := RegisterWindowMessage('SkypeControlAPIAttach'); SendMessage(HWND_BROADCAST, FSkypeAPIDiscover, Handle, 0) end;end;

8

Definindo Protocolo - Skype API

• Define qual protocolo usar– Override WndProc

procedure TSkypeAPI.WndProc(var Message: TMessage);begin if Message.Msg = FSkypeAPIAttach then begin if Message.LParam = 0 then begin FSkypeAPIWindow := Message.WParam; SendCommand('PROTOCOL '+IntTostr(FProtocol)); end else if Assigned(FOnConnectStatus) then case Message.LParam of 1: FOnConnectStatus(Self,csWaitingForConfirmation); 2: FOnConnectStatus(Self,csDenied); 3: FOnConnectStatus(Self,csNotAvailable); else FOnConnectStatus(Self,csNotAttached); end; Message.Result := 1 end else inherited;end;

9

Send Command - Skype API

• Definir parâmetros através da estrutura CopyDataStruct

procedure TSkypeAPI.SendCommand(Str: String);var CopyData: CopyDataStruct;begin if Str <> '' then begin CopyData.dwData := 0; CopyData.lpData := PChar(Str); CopyData.cbData := Length(Str)+1; SendMessage(FSkypeAPIWindow, WM_COPYDATA, Self.Handle,LPARAM(@CopyData)); end;end;

10

Receive Command - Skype API

• Espere pelo WM_COPYDATA message• lpData recebe o comando como PAnsiChar

procedure TSkypeAPI.WMCopyData(var Message: TWMCopyData);var msg : String;begin if (Message.From = FSkypeAPIWindow) and (FSkypeAPIWindow > 0) then begin msg := PAnsiChar(Message.CopyDataStruct.lpData) Message.Result := 1 end;end;

11

Skype API Wrapper

• Jason Southwell e Dr. Bob criaram o componente TSkypeAPI

– Skype API wrapper

• Código disponível no CodeCentral, facilita o uso do Skype API

12

Comandos - Skype API

• Phone Control– AUDIO IN | OUT, HOOK ON | OFF, MUTE ON | OFF, BTN_PRESSED,

BTN_RELEASED

• Voice Calls– CALL | GET CALL | SET CALL INPROGRESS | SET CALL FINISHED | SET

CALL ONHOLD | SET CALL JOIN CONFERENCE | SET CALL DTMF | SET CALL SEEN | ALTER CALL | GET CALL CAN TRANSFER | ALTER CALL TRANSFER

• Managing call forwarding– GET PROFILE CALL APPLY CF | SET PROFILE CALL APPLY CF | GET

PROFILE CALL FORWARD RULES | SET PROFILE CALL FORWARD RULES | GET PROFILE CALL NOANSWER TIMEOUT | SET PROFILE CALL NOANSWER TIMEOUT | GET PROFILE CALL SEND TO VM | SET PROFILE CALL SEND TO VM |

13

Comandos - Skype API

• Sending and managing SMS messages– CREATE SMS | SET SMS BODY | ALTER SMS SEND | SET SMS SEEN | SET

SMS REPLY TO NUMBER | SET SMS TARGET NUMBERS

• Custom Application Communication– AP2AP CREATE | AP2AP CONNECT | AP2AP WRITE | AP2AP DATAGRAM |

AP2AP READ | AP2AP DISCONNECT | AP2AP DELETE

• Making and managing video calls– GET VIDEO IN | SET VIDEO IN | GET CALL VIDEO STATUS | ALTER CALL

VIDEO SEND | ALTER CALL VIDEO RECEIVE | GET CALL VIDEO SEND STATUS | GET CALL VIDEO RECEIVE STATUS | IS VIDEO CAPABLE | OPEN VIDEOTEST | OPEN OPTIONS VIDEO

14

Comandos - Skype API

• Managing contacts and groups– GET GROUP USERS | GET GROUP VISIBLE | GET GROUP EXPANDED | GET

GROUP DISPLAYNAME | SET GROUP DISPLAYNAME | GET GROUP TYPE | CREATE GROUP | DELETE GROUP | ALTER GROUP ADDUSER | ALTER GROUP REMOVEUSER | SET USER DISPLAYNAME

• Lista completa de comandos– https://developer.skype.com/Docs/ApiDoc/Commands

15

Demo Skype API

16

O que você precisa para usar Skype4COM

• Instalação– Skype: http://www.skype.com– Skype4COM.dll

• http://developer.skype.com/accessories

– Precisa registrar a DLL

• Object Wrapper para API• Ajuda a entender os comandos da API

17

Objetos principais - Skype4COM

• Skype (ISkype)– Core integration object– Fornece acesso a maioria dos objetos– Componente “Visual” quando importado– Drop no form o crie em runtime

• Application (IApplication)– Crie aplicações p2p usando o Skype framework– IApplication tem conflito com VCL TApplication, referencie Forms.Application

para evitar este problema

18

Demo Skype4COM

• Usando VCL• Usando TMS Smooth Controls

19

Exemplos

• Código fonte disponível para download– http://cc.embarcadero.com/Item/27742

20

Perguntas

• EDN – Embarcadero Developer Network– http://edn.embarcadero.com/br (Artigos e Vídeos)

• Trial Download– http://www.embarcadero.com/downloads

• Código fonte disponível para download– http://cc.embarcadero.com/Item/27742

21

Dados para Contato

• Email:Andreano.Lanusse@embarcadero.com

• Blog:http://www.andreanolanusse.com

• Twitter:http://twitter.com/andreanolanusse