Download - Integrando Skype em aplicações Delphi

Transcript
Page 1: Integrando Skype em aplicações Delphi

1

Integrando Skype em aplicações Delphi

Andreano Lanusse

Technical Lead Evangelist, Developer Relations

Page 2: Integrando Skype em aplicações Delphi

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

Page 3: Integrando Skype em aplicações Delphi

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

Page 4: Integrando Skype em aplicações Delphi

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

Page 5: Integrando Skype em aplicações Delphi

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

Page 6: Integrando Skype em aplicações Delphi

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

Page 7: Integrando Skype em aplicações Delphi

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;

Page 8: Integrando Skype em aplicações Delphi

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;

Page 9: Integrando Skype em aplicações Delphi

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;

Page 10: Integrando Skype em aplicações Delphi

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;

Page 11: Integrando Skype em aplicações Delphi

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

Page 12: Integrando Skype em aplicações Delphi

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 |

Page 13: Integrando Skype em aplicações Delphi

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

Page 14: Integrando Skype em aplicações Delphi

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

Page 15: Integrando Skype em aplicações Delphi

15

Demo Skype API

Page 16: Integrando Skype em aplicações Delphi

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

Page 17: Integrando Skype em aplicações Delphi

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

Page 18: Integrando Skype em aplicações Delphi

18

Demo Skype4COM

• Usando VCL• Usando TMS Smooth Controls

Page 19: Integrando Skype em aplicações Delphi

19

Exemplos

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

Page 20: Integrando Skype em aplicações Delphi

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

Page 21: Integrando Skype em aplicações Delphi

21

Dados para Contato

• Email:[email protected]

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

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