├── .DS_Store
├── ChatDemo.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ ├── xcshareddata
│ │ └── ChatDemo.xccheckout
│ └── xcuserdata
│ │ └── harvey.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ ├── harvey.xcuserdatad
│ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ │ ├── ChatDemo.xcscheme
│ │ └── xcschememanagement.plist
│ └── root.xcuserdatad
│ ├── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
│ └── xcschemes
│ ├── ChatDemo.xcscheme
│ └── xcschememanagement.plist
├── ChatDemo
├── AddFriendViewController.h
├── AddFriendViewController.m
├── AppDelegate.h
├── AppDelegate.m
├── Base.lproj
│ └── Main.storyboard
├── ChatViewController.h
├── ChatViewController.m
├── ContactsViewController.h
├── ContactsViewController.m
├── Images.xcassets
│ ├── AppIcon.appiconset
│ │ ├── AppIcon57x57.png
│ │ ├── AppIcon57x57@2x.png
│ │ ├── AppIcon60x60@2x.png
│ │ ├── AppIcon60x60@3x.png
│ │ └── Contents.json
│ ├── LaunchImage.launchimage
│ │ ├── Contents.json
│ │ ├── LaunchImage-568h@2x.png
│ │ ├── LaunchImage.png
│ │ └── LaunchImage@2x.png
│ └── chat
│ │ ├── ReceiverTextNodeBkg.imageset
│ │ ├── Contents.json
│ │ ├── ReceiverTextNodeBkg@2x.png
│ │ └── ReceiverTextNodeBkg@3x.png
│ │ ├── ReceiverTextNodeBkgHL.imageset
│ │ ├── Contents.json
│ │ ├── ReceiverTextNodeBkgHL@2x.png
│ │ └── ReceiverTextNodeBkgHL@3x.png
│ │ ├── SenderTextNodeBkg.imageset
│ │ ├── Contents.json
│ │ ├── SenderTextNodeBkg@2x.png
│ │ └── SenderTextNodeBkg@3x.png
│ │ └── SenderTextNodeBkgHL.imageset
│ │ ├── Contents.json
│ │ ├── SenderTextNodeBkgHL@2x.png
│ │ └── SenderTextNodeBkgHL@3x.png
├── Info.plist
├── PrefixHeader.pch
├── RegistViewController.h
├── RegistViewController.m
├── Resources
│ └── Images
│ │ ├── Address_IconHl@2x.png
│ │ ├── Address_IconHl@3x.png
│ │ ├── LaunchImage-568h@2x.png
│ │ ├── LaunchImage.png
│ │ ├── LaunchImage@2x.png
│ │ ├── LoginBackground@2x.png
│ │ ├── aisi.jpg
│ │ ├── chat
│ │ ├── ReceiverTextNodeBkg@2x.png
│ │ ├── ReceiverTextNodeBkg@3x.png
│ │ ├── ReceiverTextNodeBkgHL@2x.png
│ │ ├── ReceiverTextNodeBkgHL@3x.png
│ │ ├── SenderTextNodeBkg@2x.png
│ │ ├── SenderTextNodeBkg@3x.png
│ │ ├── SenderTextNodeBkgHL@2x.png
│ │ └── SenderTextNodeBkgHL@3x.png
│ │ ├── lufei.jpeg
│ │ ├── screenShot
│ │ ├── Shot1.png
│ │ ├── Shot2.png
│ │ ├── Shot3.png
│ │ └── Shot4.png
│ │ ├── tabbar_disc@2x.png
│ │ ├── tabbar_disc_hover@2x.png
│ │ ├── tabbar_mates@2x.png
│ │ ├── tabbar_mates_hover@2x.png
│ │ ├── tabbar_more@2x.png
│ │ ├── tabbar_more_hover@2x.png
│ │ └── wechat.png
├── RoomsViewController.h
├── RoomsViewController.m
├── SettingViewController.h
├── SettingViewController.m
├── Tools
│ ├── JKXMPPTool.h
│ └── JKXMPPTool.m
├── ViewController.h
├── ViewController.m
├── XMPP
│ ├── Authentication
│ │ ├── Anonymous
│ │ │ ├── XMPPAnonymousAuthentication.h
│ │ │ └── XMPPAnonymousAuthentication.m
│ │ ├── Deprecated-Digest
│ │ │ ├── XMPPDeprecatedDigestAuthentication.h
│ │ │ └── XMPPDeprecatedDigestAuthentication.m
│ │ ├── Deprecated-Plain
│ │ │ ├── XMPPDeprecatedPlainAuthentication.h
│ │ │ └── XMPPDeprecatedPlainAuthentication.m
│ │ ├── Digest-MD5
│ │ │ ├── XMPPDigestMD5Authentication.h
│ │ │ └── XMPPDigestMD5Authentication.m
│ │ ├── Plain
│ │ │ ├── XMPPPlainAuthentication.h
│ │ │ └── XMPPPlainAuthentication.m
│ │ ├── SCRAM-SHA-1
│ │ │ ├── XMPPSCRAMSHA1Authentication.h
│ │ │ └── XMPPSCRAMSHA1Authentication.m
│ │ ├── X-Facebook-Platform
│ │ │ ├── XMPPXFacebookPlatformAuthentication.h
│ │ │ └── XMPPXFacebookPlatformAuthentication.m
│ │ ├── X-OAuth2-Google
│ │ │ ├── XMPPXOAuth2Google.h
│ │ │ └── XMPPXOAuth2Google.m
│ │ ├── XMPPCustomBinding.h
│ │ └── XMPPSASLAuthentication.h
│ ├── Categories
│ │ ├── NSData+XMPP.h
│ │ ├── NSData+XMPP.m
│ │ ├── NSNumber+XMPP.h
│ │ ├── NSNumber+XMPP.m
│ │ ├── NSXMLElement+XMPP.h
│ │ └── NSXMLElement+XMPP.m
│ ├── Core
│ │ ├── XMPP.h
│ │ ├── XMPPConstants.h
│ │ ├── XMPPConstants.m
│ │ ├── XMPPElement.h
│ │ ├── XMPPElement.m
│ │ ├── XMPPIQ.h
│ │ ├── XMPPIQ.m
│ │ ├── XMPPInternal.h
│ │ ├── XMPPJID.h
│ │ ├── XMPPJID.m
│ │ ├── XMPPLogging.h
│ │ ├── XMPPMessage.h
│ │ ├── XMPPMessage.m
│ │ ├── XMPPModule.h
│ │ ├── XMPPModule.m
│ │ ├── XMPPParser.h
│ │ ├── XMPPParser.m
│ │ ├── XMPPPresence.h
│ │ ├── XMPPPresence.m
│ │ ├── XMPPStream.h
│ │ └── XMPPStream.m
│ ├── Extensions
│ │ ├── BandwidthMonitor
│ │ │ ├── XMPPBandwidthMonitor.h
│ │ │ └── XMPPBandwidthMonitor.m
│ │ ├── CoreDataStorage
│ │ │ ├── XMPPCoreDataStorage.h
│ │ │ ├── XMPPCoreDataStorage.m
│ │ │ └── XMPPCoreDataStorageProtected.h
│ │ ├── FileTransfer
│ │ │ ├── XMPPFileTransfer.h
│ │ │ ├── XMPPFileTransfer.m
│ │ │ ├── XMPPIncomingFileTransfer.h
│ │ │ ├── XMPPIncomingFileTransfer.m
│ │ │ ├── XMPPOutgoingFileTransfer.h
│ │ │ └── XMPPOutgoingFileTransfer.m
│ │ ├── GoogleSharedStatus
│ │ │ ├── XMPPGoogleSharedStatus.h
│ │ │ └── XMPPGoogleSharedStatus.m
│ │ ├── ProcessOne
│ │ │ ├── XMPPProcessOne.h
│ │ │ └── XMPPProcessOne.m
│ │ ├── Reconnect
│ │ │ ├── XMPPReconnect.h
│ │ │ └── XMPPReconnect.m
│ │ ├── Roster
│ │ │ ├── CoreDataStorage
│ │ │ │ ├── XMPPGroupCoreDataStorageObject.h
│ │ │ │ ├── XMPPGroupCoreDataStorageObject.m
│ │ │ │ ├── XMPPResourceCoreDataStorageObject.h
│ │ │ │ ├── XMPPResourceCoreDataStorageObject.m
│ │ │ │ ├── XMPPRoster.xcdatamodel
│ │ │ │ │ ├── elements
│ │ │ │ │ └── layout
│ │ │ │ ├── XMPPRosterCoreDataStorage.h
│ │ │ │ ├── XMPPRosterCoreDataStorage.m
│ │ │ │ ├── XMPPUserCoreDataStorageObject.h
│ │ │ │ └── XMPPUserCoreDataStorageObject.m
│ │ │ ├── MemoryStorage
│ │ │ │ ├── XMPPResourceMemoryStorageObject.h
│ │ │ │ ├── XMPPResourceMemoryStorageObject.m
│ │ │ │ ├── XMPPRosterMemoryStorage.h
│ │ │ │ ├── XMPPRosterMemoryStorage.m
│ │ │ │ ├── XMPPRosterMemoryStoragePrivate.h
│ │ │ │ ├── XMPPUserMemoryStorageObject.h
│ │ │ │ └── XMPPUserMemoryStorageObject.m
│ │ │ ├── XMPPResource.h
│ │ │ ├── XMPPRoster.h
│ │ │ ├── XMPPRoster.m
│ │ │ ├── XMPPRosterPrivate.h
│ │ │ └── XMPPUser.h
│ │ ├── SystemInputActivityMonitor
│ │ │ ├── XMPPSystemInputActivityMonitor.h
│ │ │ └── XMPPSystemInputActivityMonitor.m
│ │ ├── XEP-0009
│ │ │ ├── XMPPIQ+JabberRPC.h
│ │ │ ├── XMPPIQ+JabberRPC.m
│ │ │ ├── XMPPIQ+JabberRPCResonse.h
│ │ │ ├── XMPPIQ+JabberRPCResonse.m
│ │ │ ├── XMPPJabberRPCModule.h
│ │ │ └── XMPPJabberRPCModule.m
│ │ ├── XEP-0012
│ │ │ ├── XMPPIQ+LastActivity.h
│ │ │ ├── XMPPIQ+LastActivity.m
│ │ │ ├── XMPPLastActivity.h
│ │ │ └── XMPPLastActivity.m
│ │ ├── XEP-0016
│ │ │ ├── XMPPPrivacy.h
│ │ │ └── XMPPPrivacy.m
│ │ ├── XEP-0045
│ │ │ ├── CoreDataStorage
│ │ │ │ ├── XMPPRoom.xcdatamodeld
│ │ │ │ │ ├── .xccurrentversion
│ │ │ │ │ └── XMPPRoom.xcdatamodel
│ │ │ │ │ │ └── contents
│ │ │ │ ├── XMPPRoomCoreDataStorage.h
│ │ │ │ ├── XMPPRoomCoreDataStorage.m
│ │ │ │ ├── XMPPRoomMessageCoreDataStorageObject.h
│ │ │ │ ├── XMPPRoomMessageCoreDataStorageObject.m
│ │ │ │ ├── XMPPRoomOccupantCoreDataStorageObject.h
│ │ │ │ └── XMPPRoomOccupantCoreDataStorageObject.m
│ │ │ ├── HybridStorage
│ │ │ │ ├── XMPPRoomHybrid.xcdatamodeld
│ │ │ │ │ ├── .xccurrentversion
│ │ │ │ │ └── XMPPRoomHybrid.xcdatamodel
│ │ │ │ │ │ └── contents
│ │ │ │ ├── XMPPRoomHybridStorage.h
│ │ │ │ ├── XMPPRoomHybridStorage.m
│ │ │ │ ├── XMPPRoomHybridStorageProtected.h
│ │ │ │ ├── XMPPRoomMessageHybridCoreDataStorageObject.h
│ │ │ │ ├── XMPPRoomMessageHybridCoreDataStorageObject.m
│ │ │ │ ├── XMPPRoomOccupantHybridMemoryStorageObject.h
│ │ │ │ └── XMPPRoomOccupantHybridMemoryStorageObject.m
│ │ │ ├── MemoryStorage
│ │ │ │ ├── XMPPRoomMemoryStorage.h
│ │ │ │ ├── XMPPRoomMemoryStorage.m
│ │ │ │ ├── XMPPRoomMessageMemoryStorageObject.h
│ │ │ │ ├── XMPPRoomMessageMemoryStorageObject.m
│ │ │ │ ├── XMPPRoomOccupantMemoryStorageObject.h
│ │ │ │ └── XMPPRoomOccupantMemoryStorageObject.m
│ │ │ ├── XMPPMUC.h
│ │ │ ├── XMPPMUC.m
│ │ │ ├── XMPPMessage+XEP0045.h
│ │ │ ├── XMPPMessage+XEP0045.m
│ │ │ ├── XMPPRoom.h
│ │ │ ├── XMPPRoom.m
│ │ │ ├── XMPPRoomMessage.h
│ │ │ ├── XMPPRoomOccupant.h
│ │ │ └── XMPPRoomPrivate.h
│ │ ├── XEP-0054
│ │ │ ├── CoreDataStorage
│ │ │ │ ├── XMPPvCard.xcdatamodeld
│ │ │ │ │ ├── .xccurrentversion
│ │ │ │ │ └── XMPPvCard.xcdatamodel
│ │ │ │ │ │ ├── elements
│ │ │ │ │ │ └── layout
│ │ │ │ ├── XMPPvCardAvatarCoreDataStorageObject.h
│ │ │ │ ├── XMPPvCardAvatarCoreDataStorageObject.m
│ │ │ │ ├── XMPPvCardCoreDataStorage.h
│ │ │ │ ├── XMPPvCardCoreDataStorage.m
│ │ │ │ ├── XMPPvCardCoreDataStorageObject.h
│ │ │ │ ├── XMPPvCardCoreDataStorageObject.m
│ │ │ │ ├── XMPPvCardTempCoreDataStorageObject.h
│ │ │ │ └── XMPPvCardTempCoreDataStorageObject.m
│ │ │ ├── XMPPvCardTemp.h
│ │ │ ├── XMPPvCardTemp.m
│ │ │ ├── XMPPvCardTempAdr.h
│ │ │ ├── XMPPvCardTempAdr.m
│ │ │ ├── XMPPvCardTempAdrTypes.h
│ │ │ ├── XMPPvCardTempAdrTypes.m
│ │ │ ├── XMPPvCardTempBase.h
│ │ │ ├── XMPPvCardTempBase.m
│ │ │ ├── XMPPvCardTempEmail.h
│ │ │ ├── XMPPvCardTempEmail.m
│ │ │ ├── XMPPvCardTempLabel.h
│ │ │ ├── XMPPvCardTempLabel.m
│ │ │ ├── XMPPvCardTempModule.h
│ │ │ ├── XMPPvCardTempModule.m
│ │ │ ├── XMPPvCardTempTel.h
│ │ │ └── XMPPvCardTempTel.m
│ │ ├── XEP-0059
│ │ │ ├── NSXMLElement+XEP_0059.h
│ │ │ ├── NSXMLElement+XEP_0059.m
│ │ │ ├── XMPPResultSet.h
│ │ │ └── XMPPResultSet.m
│ │ ├── XEP-0060
│ │ │ ├── XMPPIQ+XEP_0060.h
│ │ │ ├── XMPPIQ+XEP_0060.m
│ │ │ ├── XMPPPubSub.h
│ │ │ └── XMPPPubSub.m
│ │ ├── XEP-0065
│ │ │ ├── TURNSocket.h
│ │ │ └── TURNSocket.m
│ │ ├── XEP-0066
│ │ │ ├── XMPPIQ+XEP_0066.h
│ │ │ ├── XMPPIQ+XEP_0066.m
│ │ │ ├── XMPPMessage+XEP_0066.h
│ │ │ └── XMPPMessage+XEP_0066.m
│ │ ├── XEP-0077
│ │ │ ├── XMPPRegistration.h
│ │ │ └── XMPPRegistration.m
│ │ ├── XEP-0082
│ │ │ ├── NSDate+XMPPDateTimeProfiles.h
│ │ │ ├── NSDate+XMPPDateTimeProfiles.m
│ │ │ ├── XMPPDateTimeProfiles.h
│ │ │ └── XMPPDateTimeProfiles.m
│ │ ├── XEP-0085
│ │ │ ├── XMPPMessage+XEP_0085.h
│ │ │ └── XMPPMessage+XEP_0085.m
│ │ ├── XEP-0092
│ │ │ ├── XMPPSoftwareVersion.h
│ │ │ └── XMPPSoftwareVersion.m
│ │ ├── XEP-0100
│ │ │ ├── XMPPTransports.h
│ │ │ └── XMPPTransports.m
│ │ ├── XEP-0106
│ │ │ ├── NSString+XEP_0106.h
│ │ │ └── NSString+XEP_0106.m
│ │ ├── XEP-0115
│ │ │ ├── CoreDataStorage
│ │ │ │ ├── XMPPCapabilities.xcdatamodel
│ │ │ │ │ ├── elements
│ │ │ │ │ └── layout
│ │ │ │ ├── XMPPCapabilitiesCoreDataStorage.h
│ │ │ │ ├── XMPPCapabilitiesCoreDataStorage.m
│ │ │ │ ├── XMPPCapsCoreDataStorageObject.h
│ │ │ │ ├── XMPPCapsCoreDataStorageObject.m
│ │ │ │ ├── XMPPCapsResourceCoreDataStorageObject.h
│ │ │ │ └── XMPPCapsResourceCoreDataStorageObject.m
│ │ │ ├── XMPPCapabilities.h
│ │ │ └── XMPPCapabilities.m
│ │ ├── XEP-0136
│ │ │ ├── CoreDataStorage
│ │ │ │ ├── XMPPMessageArchiving.xcdatamodeld
│ │ │ │ │ ├── .xccurrentversion
│ │ │ │ │ └── XMPPMessageArchiving.xcdatamodel
│ │ │ │ │ │ └── contents
│ │ │ │ ├── XMPPMessageArchivingCoreDataStorage.h
│ │ │ │ ├── XMPPMessageArchivingCoreDataStorage.m
│ │ │ │ ├── XMPPMessageArchiving_Contact_CoreDataObject.h
│ │ │ │ ├── XMPPMessageArchiving_Contact_CoreDataObject.m
│ │ │ │ ├── XMPPMessageArchiving_Message_CoreDataObject.h
│ │ │ │ └── XMPPMessageArchiving_Message_CoreDataObject.m
│ │ │ ├── XMPPMessageArchiving.h
│ │ │ └── XMPPMessageArchiving.m
│ │ ├── XEP-0153
│ │ │ ├── XMPPvCardAvatarModule.h
│ │ │ └── XMPPvCardAvatarModule.m
│ │ ├── XEP-0172
│ │ │ ├── XMPPMessage+XEP_0172.h
│ │ │ ├── XMPPMessage+XEP_0172.m
│ │ │ ├── XMPPPresence+XEP_0172.h
│ │ │ └── XMPPPresence+XEP_0172.m
│ │ ├── XEP-0184
│ │ │ ├── XMPPMessage+XEP_0184.h
│ │ │ ├── XMPPMessage+XEP_0184.m
│ │ │ ├── XMPPMessageDeliveryReceipts.h
│ │ │ └── XMPPMessageDeliveryReceipts.m
│ │ ├── XEP-0191
│ │ │ ├── XMPPBlocking.h
│ │ │ └── XMPPBlocking.m
│ │ ├── XEP-0198
│ │ │ ├── Memory Storage
│ │ │ │ ├── XMPPStreamManagementMemoryStorage.h
│ │ │ │ └── XMPPStreamManagementMemoryStorage.m
│ │ │ ├── Private
│ │ │ │ ├── XMPPStreamManagementStanzas.h
│ │ │ │ └── XMPPStreamManagementStanzas.m
│ │ │ ├── XMPPStreamManagement.h
│ │ │ └── XMPPStreamManagement.m
│ │ ├── XEP-0199
│ │ │ ├── XMPPAutoPing.h
│ │ │ ├── XMPPAutoPing.m
│ │ │ ├── XMPPPing.h
│ │ │ └── XMPPPing.m
│ │ ├── XEP-0202
│ │ │ ├── XMPPAutoTime.h
│ │ │ ├── XMPPAutoTime.m
│ │ │ ├── XMPPTime.h
│ │ │ └── XMPPTime.m
│ │ ├── XEP-0203
│ │ │ ├── NSXMLElement+XEP_0203.h
│ │ │ └── NSXMLElement+XEP_0203.m
│ │ ├── XEP-0223
│ │ │ ├── XEP_0223.h
│ │ │ └── XEP_0223.m
│ │ ├── XEP-0224
│ │ │ ├── XMPPAttentionModule.h
│ │ │ ├── XMPPAttentionModule.m
│ │ │ ├── XMPPMessage+XEP_0224.h
│ │ │ └── XMPPMessage+XEP_0224.m
│ │ ├── XEP-0280
│ │ │ ├── XMPPMessage+XEP_0280.h
│ │ │ ├── XMPPMessage+XEP_0280.m
│ │ │ ├── XMPPMessageCarbons.h
│ │ │ └── XMPPMessageCarbons.m
│ │ ├── XEP-0297
│ │ │ ├── NSXMLElement+XEP_0297.h
│ │ │ └── NSXMLElement+XEP_0297.m
│ │ ├── XEP-0308
│ │ │ ├── XMPPMessage+XEP_0308.h
│ │ │ └── XMPPMessage+XEP_0308.m
│ │ ├── XEP-0333
│ │ │ ├── XMPPMessage+XEP_0333.h
│ │ │ └── XMPPMessage+XEP_0333.m
│ │ └── XEP-0335
│ │ │ ├── NSXMLElement+XEP_0335.h
│ │ │ └── NSXMLElement+XEP_0335.m
│ ├── Utilities
│ │ ├── DDList.h
│ │ ├── DDList.m
│ │ ├── GCDMulticastDelegate.h
│ │ ├── GCDMulticastDelegate.m
│ │ ├── RFImageToDataTransformer.h
│ │ ├── RFImageToDataTransformer.m
│ │ ├── XMPPIDTracker.h
│ │ ├── XMPPIDTracker.m
│ │ ├── XMPPSRVResolver.h
│ │ ├── XMPPSRVResolver.m
│ │ ├── XMPPStringPrep.h
│ │ ├── XMPPStringPrep.m
│ │ ├── XMPPTimer.h
│ │ └── XMPPTimer.m
│ ├── Vendor
│ │ ├── CocoaAsyncSocket
│ │ │ ├── GCDAsyncSocket.h
│ │ │ └── GCDAsyncSocket.m
│ │ ├── CocoaLumberjack
│ │ │ ├── DDASLLogger.h
│ │ │ ├── DDASLLogger.m
│ │ │ ├── DDAbstractDatabaseLogger.h
│ │ │ ├── DDAbstractDatabaseLogger.m
│ │ │ ├── DDFileLogger.h
│ │ │ ├── DDFileLogger.m
│ │ │ ├── DDLog+LOGV.h
│ │ │ ├── DDLog.h
│ │ │ ├── DDLog.m
│ │ │ ├── DDTTYLogger.h
│ │ │ ├── DDTTYLogger.m
│ │ │ └── Extensions
│ │ │ │ ├── DDContextFilterLogFormatter.h
│ │ │ │ ├── DDContextFilterLogFormatter.m
│ │ │ │ ├── DDDispatchQueueLogFormatter.h
│ │ │ │ ├── DDDispatchQueueLogFormatter.m
│ │ │ │ ├── DDMultiFormatter.h
│ │ │ │ ├── DDMultiFormatter.m
│ │ │ │ └── README.txt
│ │ ├── KissXML
│ │ │ ├── Categories
│ │ │ │ ├── NSString+DDXML.h
│ │ │ │ └── NSString+DDXML.m
│ │ │ ├── DDXML.h
│ │ │ ├── DDXMLDocument.h
│ │ │ ├── DDXMLDocument.m
│ │ │ ├── DDXMLElement.h
│ │ │ ├── DDXMLElement.m
│ │ │ ├── DDXMLNode.h
│ │ │ ├── DDXMLNode.m
│ │ │ └── Private
│ │ │ │ └── DDXMLPrivate.h
│ │ └── libidn
│ │ │ ├── build-libidn.sh
│ │ │ ├── idn-int.h
│ │ │ ├── libidn.a
│ │ │ └── stringprep.h
│ └── XMPPFramework.h
├── main.m
└── zh-Hans.lproj
│ └── Main.strings
└── README.md
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/.DS_Store
--------------------------------------------------------------------------------
/ChatDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ChatDemo.xcodeproj/project.xcworkspace/xcshareddata/ChatDemo.xccheckout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDESourceControlProjectFavoriteDictionaryKey
6 |
7 | IDESourceControlProjectIdentifier
8 | E89481CC-D68F-4534-8EB5-1042AB86E7EB
9 | IDESourceControlProjectName
10 | ChatDemo
11 | IDESourceControlProjectOriginsDictionary
12 |
13 | A3CB6F416919E98CDCE02616600D35142A6C455D
14 | https://github.com/Joker-King/ChatDemo.git
15 |
16 | IDESourceControlProjectPath
17 | ChatDemo.xcodeproj
18 | IDESourceControlProjectRelativeInstallPathDictionary
19 |
20 | A3CB6F416919E98CDCE02616600D35142A6C455D
21 | ../..
22 |
23 | IDESourceControlProjectURL
24 | https://github.com/Joker-King/ChatDemo.git
25 | IDESourceControlProjectVersion
26 | 111
27 | IDESourceControlProjectWCCIdentifier
28 | A3CB6F416919E98CDCE02616600D35142A6C455D
29 | IDESourceControlProjectWCConfigurations
30 |
31 |
32 | IDESourceControlRepositoryExtensionIdentifierKey
33 | public.vcs.git
34 | IDESourceControlWCCIdentifierKey
35 | A3CB6F416919E98CDCE02616600D35142A6C455D
36 | IDESourceControlWCCName
37 | ChatDemo
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/ChatDemo.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo.xcodeproj/project.xcworkspace/xcuserdata/harvey.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/ChatDemo.xcodeproj/xcuserdata/harvey.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/ChatDemo.xcodeproj/xcuserdata/harvey.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | ChatDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 610850761B5B6054006067DD
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/ChatDemo.xcodeproj/xcuserdata/root.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/ChatDemo.xcodeproj/xcuserdata/root.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | ChatDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 610850761B5B6054006067DD
16 |
17 | primary
18 |
19 |
20 | 6108508F1B5B6054006067DD
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/ChatDemo/AddFriendViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // AddFriendViewController.h
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/22.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AddFriendViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ChatDemo/AddFriendViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // AddFriendViewController.m
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/22.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #import "AddFriendViewController.h"
10 | #import "JKXMPPTool.h"
11 |
12 | @interface AddFriendViewController ()
13 |
14 | @property (weak, nonatomic) IBOutlet UITextField *usernameField;
15 | @end
16 |
17 | @implementation AddFriendViewController
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | // Do any additional setup after loading the view.
22 | }
23 |
24 | - (void)didReceiveMemoryWarning {
25 | [super didReceiveMemoryWarning];
26 | // Dispose of any resources that can be recreated.
27 | }
28 |
29 | - (IBAction)addFriendClick:(id)sender {
30 | NSString *username = _usernameField.text;
31 | if (username.length <= 0) {
32 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"用户名未填写" delegate:nil cancelButtonTitle:@"我知道了" otherButtonTitles:nil];
33 | [alertView show];
34 | return;
35 | }
36 |
37 | [[JKXMPPTool sharedInstance] addFriend:[XMPPJID jidWithUser:username domain:kXMPP_DOMAIN resource:kXMPP_RESOURCE]];
38 | [self.navigationController popViewControllerAnimated:YES];
39 | }
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/ChatDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/19.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/ChatDemo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/19.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/ChatDemo/ChatViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ChatViewController.h
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/22.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface ChatViewController : UIViewController
13 |
14 | @property (nonatomic, strong) XMPPJID *chatJID;
15 | /** 聊天记录*/
16 | @property (nonatomic, strong) NSMutableArray *chatHistory;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/ChatDemo/ContactsViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ContactsViewController.h
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/21.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ContactsViewController : UITableViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/AppIcon.appiconset/AppIcon57x57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/AppIcon.appiconset/AppIcon57x57.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/AppIcon.appiconset/AppIcon57x57@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/AppIcon.appiconset/AppIcon57x57@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/AppIcon.appiconset/AppIcon60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/AppIcon.appiconset/AppIcon60x60@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/AppIcon.appiconset/AppIcon60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/AppIcon.appiconset/AppIcon60x60@3x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "3x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "3x"
27 | },
28 | {
29 | "size" : "57x57",
30 | "idiom" : "iphone",
31 | "filename" : "AppIcon57x57.png",
32 | "scale" : "1x"
33 | },
34 | {
35 | "size" : "57x57",
36 | "idiom" : "iphone",
37 | "filename" : "AppIcon57x57@2x.png",
38 | "scale" : "2x"
39 | },
40 | {
41 | "size" : "60x60",
42 | "idiom" : "iphone",
43 | "filename" : "AppIcon60x60@2x.png",
44 | "scale" : "2x"
45 | },
46 | {
47 | "size" : "60x60",
48 | "idiom" : "iphone",
49 | "filename" : "AppIcon60x60@3x.png",
50 | "scale" : "3x"
51 | },
52 | {
53 | "idiom" : "ipad",
54 | "size" : "29x29",
55 | "scale" : "1x"
56 | },
57 | {
58 | "idiom" : "ipad",
59 | "size" : "29x29",
60 | "scale" : "2x"
61 | },
62 | {
63 | "idiom" : "ipad",
64 | "size" : "40x40",
65 | "scale" : "1x"
66 | },
67 | {
68 | "idiom" : "ipad",
69 | "size" : "40x40",
70 | "scale" : "2x"
71 | },
72 | {
73 | "idiom" : "ipad",
74 | "size" : "50x50",
75 | "scale" : "1x"
76 | },
77 | {
78 | "idiom" : "ipad",
79 | "size" : "50x50",
80 | "scale" : "2x"
81 | },
82 | {
83 | "idiom" : "ipad",
84 | "size" : "72x72",
85 | "scale" : "1x"
86 | },
87 | {
88 | "idiom" : "ipad",
89 | "size" : "72x72",
90 | "scale" : "2x"
91 | },
92 | {
93 | "idiom" : "ipad",
94 | "size" : "76x76",
95 | "scale" : "1x"
96 | },
97 | {
98 | "idiom" : "ipad",
99 | "size" : "76x76",
100 | "scale" : "2x"
101 | }
102 | ],
103 | "info" : {
104 | "version" : 1,
105 | "author" : "xcode"
106 | }
107 | }
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "filename" : "LaunchImage@2x.png",
9 | "scale" : "2x"
10 | },
11 | {
12 | "extent" : "full-screen",
13 | "idiom" : "iphone",
14 | "subtype" : "retina4",
15 | "filename" : "LaunchImage-568h@2x.png",
16 | "minimum-system-version" : "7.0",
17 | "orientation" : "portrait",
18 | "scale" : "2x"
19 | },
20 | {
21 | "orientation" : "portrait",
22 | "idiom" : "iphone",
23 | "extent" : "full-screen",
24 | "filename" : "LaunchImage.png",
25 | "scale" : "1x"
26 | }
27 | ],
28 | "info" : {
29 | "version" : 1,
30 | "author" : "xcode"
31 | }
32 | }
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage-568h@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/LaunchImage.launchimage/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/ReceiverTextNodeBkg.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "ReceiverTextNodeBkg@2x.png"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x",
15 | "filename" : "ReceiverTextNodeBkg@3x.png"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/ReceiverTextNodeBkg.imageset/ReceiverTextNodeBkg@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/chat/ReceiverTextNodeBkg.imageset/ReceiverTextNodeBkg@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/ReceiverTextNodeBkg.imageset/ReceiverTextNodeBkg@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/chat/ReceiverTextNodeBkg.imageset/ReceiverTextNodeBkg@3x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/ReceiverTextNodeBkgHL.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "ReceiverTextNodeBkgHL@2x.png"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x",
15 | "filename" : "ReceiverTextNodeBkgHL@3x.png"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/ReceiverTextNodeBkgHL.imageset/ReceiverTextNodeBkgHL@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/chat/ReceiverTextNodeBkgHL.imageset/ReceiverTextNodeBkgHL@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/ReceiverTextNodeBkgHL.imageset/ReceiverTextNodeBkgHL@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/chat/ReceiverTextNodeBkgHL.imageset/ReceiverTextNodeBkgHL@3x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/SenderTextNodeBkg.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "SenderTextNodeBkg@2x.png"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x",
15 | "filename" : "SenderTextNodeBkg@3x.png"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/SenderTextNodeBkg.imageset/SenderTextNodeBkg@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/chat/SenderTextNodeBkg.imageset/SenderTextNodeBkg@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/SenderTextNodeBkg.imageset/SenderTextNodeBkg@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/chat/SenderTextNodeBkg.imageset/SenderTextNodeBkg@3x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/SenderTextNodeBkgHL.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "SenderTextNodeBkgHL@2x.png"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x",
15 | "filename" : "SenderTextNodeBkgHL@3x.png"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/SenderTextNodeBkgHL.imageset/SenderTextNodeBkgHL@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/chat/SenderTextNodeBkgHL.imageset/SenderTextNodeBkgHL@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Images.xcassets/chat/SenderTextNodeBkgHL.imageset/SenderTextNodeBkgHL@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Images.xcassets/chat/SenderTextNodeBkgHL.imageset/SenderTextNodeBkgHL@3x.png
--------------------------------------------------------------------------------
/ChatDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.Joker.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/ChatDemo/PrefixHeader.pch:
--------------------------------------------------------------------------------
1 | //
2 | // PrefixHeader.pch
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/19.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #ifndef ChatDemo_PrefixHeader_pch
10 | #define ChatDemo_PrefixHeader_pch
11 |
12 | // Include any system framework and library headers here that should be included in all compilation units.
13 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
14 | #ifdef __OBJC__
15 | #import
16 |
17 | #import "XMPPFramework.h"
18 | #endif
19 |
20 |
21 | #define kXMPP_HOST @"127.0.0.1"
22 | #define kXMPP_PORT 5222
23 | #define kXMPP_DOMAIN @"im.joker.cn"
24 | #define kXMPP_SUBDOMAIN @"group"
25 | #define kXMPP_RESOURCE @"iOS"
26 |
27 | //*********************** 通知 *****************
28 | #define kLOGIN_SUCCESS @"kLOGIN_SUCCESS"
29 | #define kREGIST_RESULT @"kREGIST_RESULT"
30 | #define kXMPP_ROSTER_CHANGE @"kXMPP_ROSTER_CHANGE"
31 | #define kXMPP_MESSAGE_CHANGE @"kXMPP_MESSAGE_CHANGE"
32 | #define kXMPP_GET_GROUPS @"kXMPP_GET_GROUPS"
33 |
34 | #define kScreenHeight [UIScreen mainScreen].bounds.size.height
35 | #define kScreenWidth [UIScreen mainScreen].bounds.size.width
36 |
37 | #define RGBColor(r,g,b,a) ([UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a])
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/ChatDemo/RegistViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // RegistViewController.h
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/19.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RegistViewController : UITableViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/Address_IconHl@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/Address_IconHl@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/Address_IconHl@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/Address_IconHl@3x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/LaunchImage-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/LaunchImage-568h@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/LaunchImage.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/LoginBackground@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/LoginBackground@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/aisi.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/aisi.jpg
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/chat/ReceiverTextNodeBkg@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/chat/ReceiverTextNodeBkg@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/chat/ReceiverTextNodeBkg@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/chat/ReceiverTextNodeBkg@3x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/chat/ReceiverTextNodeBkgHL@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/chat/ReceiverTextNodeBkgHL@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/chat/ReceiverTextNodeBkgHL@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/chat/ReceiverTextNodeBkgHL@3x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/chat/SenderTextNodeBkg@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/chat/SenderTextNodeBkg@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/chat/SenderTextNodeBkg@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/chat/SenderTextNodeBkg@3x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/chat/SenderTextNodeBkgHL@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/chat/SenderTextNodeBkgHL@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/chat/SenderTextNodeBkgHL@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/chat/SenderTextNodeBkgHL@3x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/lufei.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/lufei.jpeg
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/screenShot/Shot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/screenShot/Shot1.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/screenShot/Shot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/screenShot/Shot2.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/screenShot/Shot3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/screenShot/Shot3.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/screenShot/Shot4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/screenShot/Shot4.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/tabbar_disc@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/tabbar_disc@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/tabbar_disc_hover@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/tabbar_disc_hover@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/tabbar_mates@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/tabbar_mates@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/tabbar_mates_hover@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/tabbar_mates_hover@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/tabbar_more@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/tabbar_more@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/tabbar_more_hover@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/tabbar_more_hover@2x.png
--------------------------------------------------------------------------------
/ChatDemo/Resources/Images/wechat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/Resources/Images/wechat.png
--------------------------------------------------------------------------------
/ChatDemo/RoomsViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // RoomsViewController.h
3 | // ChatDemo
4 | //
5 | // Created by Haley on 16/7/22.
6 | // Copyright © 2016年 Mac. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface RoomsViewController : UITableViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ChatDemo/SettingViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SettingViewController.h
3 | // ChatDemo
4 | //
5 | // Created by Haley on 16/3/3.
6 | // Copyright © 2016年 Mac. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SettingViewController : UITableViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ChatDemo/SettingViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SettingViewController.m
3 | // ChatDemo
4 | //
5 | // Created by Haley on 16/3/3.
6 | // Copyright © 2016年 Mac. All rights reserved.
7 | //
8 |
9 | #import "SettingViewController.h"
10 | #import "JKXMPPTool.h"
11 |
12 | @interface SettingViewController ()
13 |
14 | @property (strong, nonatomic) NSArray *settingTitles; /**< 设置页标题 */
15 |
16 | @end
17 |
18 | @implementation SettingViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 |
23 | UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 60)];
24 | UIButton *exitBtn = [[UIButton alloc] initWithFrame:CGRectMake((CGRectGetWidth(self.view.frame) - 300) * 0.5, 10, 300, 40)];
25 | exitBtn.backgroundColor = [UIColor orangeColor];
26 | [exitBtn setTitle:@"退出登录" forState:UIControlStateNormal];
27 | [exitBtn addTarget:self action:@selector(logoutClick:) forControlEvents:UIControlEventTouchUpInside];
28 | [footerView addSubview:exitBtn];
29 |
30 | self.tableView.tableFooterView = footerView;
31 | }
32 |
33 | - (IBAction)logoutClick:(id)sender
34 | {
35 | [[JKXMPPTool sharedInstance] logout];
36 |
37 | [self.tabBarController dismissViewControllerAnimated:true completion:nil];
38 | }
39 |
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/ChatDemo/Tools/JKXMPPTool.h:
--------------------------------------------------------------------------------
1 | //
2 | // JKXMPPTool.h
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/19.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface JKXMPPTool : NSObject
12 |
13 | @property (nonatomic, strong) XMPPStream *xmppStream;
14 | // 模块
15 | @property (nonatomic, strong) XMPPAutoPing *xmppAutoPing;
16 | @property (nonatomic, strong) XMPPReconnect *xmppReconnect;
17 |
18 | @property (nonatomic, strong) XMPPRoster *xmppRoster;
19 | @property (nonatomic, strong) XMPPRosterMemoryStorage *xmppRosterMemoryStorage;
20 |
21 | @property (nonatomic, strong) XMPPMessageArchiving *xmppMessageArchiving;
22 | @property (nonatomic, strong) XMPPMessageArchivingCoreDataStorage *xmppMessageArchivingCoreDataStorage;
23 |
24 | @property (nonatomic, strong) XMPPIncomingFileTransfer *xmppIncomingFileTransfer;
25 |
26 | @property (nonatomic, assign) BOOL xmppNeedRegister;
27 | @property (nonatomic, copy) NSString *myPassword;
28 |
29 | @property (nonatomic, strong) XMPPPresence *receivePresence;
30 |
31 | + (instancetype)sharedInstance;
32 | - (void)loginWithJID:(XMPPJID *)JID andPassword:(NSString *)password;
33 | - (void)registerWithJID:(XMPPJID *)JID andPassword:(NSString *)password;
34 |
35 | - (void)addFriend:(XMPPJID *)aJID;
36 |
37 | /**
38 | * 退出登录
39 | */
40 | - (void)logout;
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/ChatDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/19.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/ChatDemo/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/19.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "JKXMPPTool.h"
11 |
12 | @interface ViewController ()
13 |
14 | @property (weak, nonatomic) IBOutlet UITextField *usernameField; /**< 用户名输入框 */
15 | @property (weak, nonatomic) IBOutlet UITextField *passwordField; /**< 密码输入框 */
16 | @end
17 |
18 | @implementation ViewController
19 |
20 | #pragma mark - life circle method
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 | // Do any additional setup after loading the view, typically from a nib.
24 |
25 | UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideBlackBoard)];
26 | [self.view addGestureRecognizer:tapGesture];
27 |
28 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccess) name:kLOGIN_SUCCESS object:nil];
29 | }
30 |
31 | - (void)didReceiveMemoryWarning {
32 | [super didReceiveMemoryWarning];
33 | // Dispose of any resources that can be recreated.
34 | }
35 |
36 | #pragma mark - click event
37 | /** 登录事件 */
38 | - (IBAction)loginClick:(id)sender {
39 | NSString *username = _usernameField.text;
40 | NSString *password = _passwordField.text;
41 |
42 | // username = @"1051";
43 | // password = @"209ab796311f470a98dbaa055b29523b";
44 | username = @"1021";
45 | password = @"SID:659816befbed4bc99cb225adfd285503";
46 |
47 | NSString *message = nil;
48 | if (username.length <= 0) {
49 | message = @"用户名未填写";
50 | } else if (password.length <= 0) {
51 | message = @"密码未填写";
52 | }
53 |
54 | if (message.length > 0) {
55 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"我知道了" otherButtonTitles:nil];
56 | [alertView show];
57 | } else {
58 | [[JKXMPPTool sharedInstance] loginWithJID:[XMPPJID jidWithUser:username domain:kXMPP_DOMAIN resource:kXMPP_RESOURCE] andPassword:password];
59 | }
60 | }
61 |
62 | /** 忘记密码事件 */
63 | - (IBAction)forgetClick:(id)sender {
64 |
65 | }
66 |
67 | /** 注册事件 */
68 | - (IBAction)registClick:(id)sender {
69 |
70 | }
71 |
72 | - (void)hideBlackBoard
73 | {
74 | [self.view endEditing:YES];
75 | }
76 |
77 | #pragma mark UITextFieldDelegate
78 | - (BOOL)textFieldShouldReturn:(UITextField *)textField
79 | {
80 | [self hideBlackBoard];
81 |
82 | return YES;
83 | }
84 |
85 | #pragma mark - notification event
86 | - (void)loginSuccess
87 | {
88 | NSLog(@"loginSuccess");
89 |
90 | [self performSegueWithIdentifier:@"loginSegue" sender:self];
91 | }
92 |
93 | @end
94 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Authentication/Anonymous/XMPPAnonymousAuthentication.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPSASLAuthentication.h"
3 | #import "XMPP.h"
4 |
5 |
6 | @interface XMPPAnonymousAuthentication : NSObject
7 |
8 | - (id)initWithStream:(XMPPStream *)stream;
9 |
10 | // This class implements the XMPPSASLAuthentication protocol.
11 | //
12 | // See XMPPSASLAuthentication.h for more information.
13 |
14 | @end
15 |
16 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
17 | #pragma mark -
18 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
19 |
20 | @interface XMPPStream (XMPPAnonymousAuthentication)
21 |
22 | /**
23 | * Returns whether or not the server support anonymous authentication.
24 | *
25 | * This information is available after the stream is connected.
26 | * In other words, after the delegate has received xmppStreamDidConnect: notification.
27 | **/
28 | - (BOOL)supportsAnonymousAuthentication;
29 |
30 | /**
31 | * This method attempts to start the anonymous authentication process.
32 | *
33 | * This method is asynchronous.
34 | *
35 | * If there is something immediately wrong,
36 | * such as the stream is not connected or doesn't support anonymous authentication,
37 | * the method will return NO and set the error.
38 | * Otherwise the delegate callbacks are used to communicate auth success or failure.
39 | *
40 | * @see xmppStreamDidAuthenticate:
41 | * @see xmppStream:didNotAuthenticate:
42 | **/
43 | - (BOOL)authenticateAnonymously:(NSError **)errPtr;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Authentication/Deprecated-Digest/XMPPDeprecatedDigestAuthentication.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPSASLAuthentication.h"
3 | #import "XMPPStream.h"
4 |
5 |
6 | @interface XMPPDeprecatedDigestAuthentication : NSObject
7 |
8 | // This class implements the XMPPSASLAuthentication protocol.
9 | //
10 | // See XMPPSASLAuthentication.h for more information.
11 |
12 | @end
13 |
14 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
15 | #pragma mark -
16 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
17 |
18 | @interface XMPPStream (XMPPDeprecatedDigestAuthentication)
19 |
20 | - (BOOL)supportsDeprecatedDigestAuthentication;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Authentication/Deprecated-Plain/XMPPDeprecatedPlainAuthentication.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPSASLAuthentication.h"
3 | #import "XMPPStream.h"
4 |
5 |
6 | @interface XMPPDeprecatedPlainAuthentication : NSObject
7 |
8 | // This class implements the XMPPSASLAuthentication protocol.
9 | //
10 | // See XMPPSASLAuthentication.h for more information.
11 |
12 | @end
13 |
14 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
15 | #pragma mark -
16 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
17 |
18 | @interface XMPPStream (XMPPDeprecatedPlainAuthentication)
19 |
20 | - (BOOL)supportsDeprecatedPlainAuthentication;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Authentication/Digest-MD5/XMPPDigestMD5Authentication.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPSASLAuthentication.h"
3 | #import "XMPPStream.h"
4 |
5 |
6 | @interface XMPPDigestMD5Authentication : NSObject
7 |
8 | // This class implements the XMPPSASLAuthentication protocol.
9 | //
10 | // See XMPPSASLAuthentication.h for more information.
11 |
12 | @end
13 |
14 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
15 | #pragma mark -
16 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
17 |
18 | @interface XMPPStream (XMPPDigestMD5Authentication)
19 |
20 | - (BOOL)supportsDigestMD5Authentication;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Authentication/Plain/XMPPPlainAuthentication.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPSASLAuthentication.h"
3 | #import "XMPPStream.h"
4 |
5 |
6 | @interface XMPPPlainAuthentication : NSObject
7 |
8 | // This class implements the XMPPSASLAuthentication protocol.
9 | //
10 | // See XMPPSASLAuthentication.h for more information.
11 |
12 | @end
13 |
14 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
15 | #pragma mark -
16 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
17 |
18 | @interface XMPPStream (XMPPPlainAuthentication)
19 |
20 | - (BOOL)supportsPlainAuthentication;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Authentication/SCRAM-SHA-1/XMPPSCRAMSHA1Authentication.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPSCRAMSHA1Authentication.h
3 | // iPhoneXMPP
4 | //
5 | // Created by David Chiles on 3/21/14.
6 | //
7 | //
8 |
9 | #import
10 | #import "XMPPSASLAuthentication.h"
11 | #import "XMPPStream.h"
12 |
13 | @interface XMPPSCRAMSHA1Authentication : NSObject
14 |
15 | @end
16 |
17 | @interface XMPPStream (XMPPSCRAMSHA1Authentication)
18 |
19 | - (BOOL)supportsSCRAMSHA1Authentication;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Authentication/X-Facebook-Platform/XMPPXFacebookPlatformAuthentication.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPSASLAuthentication.h"
3 | #import "XMPPStream.h"
4 |
5 |
6 | @interface XMPPXFacebookPlatformAuthentication : NSObject
7 |
8 | /**
9 | * You should use this init method (as opposed the one defined in the XMPPSASLAuthentication protocol).
10 | **/
11 | - (id)initWithStream:(XMPPStream *)stream appId:(NSString *)appId accessToken:(NSString *)accessToken;
12 |
13 | @end
14 |
15 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 | #pragma mark -
17 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
18 |
19 | @interface XMPPStream (XMPPXFacebookPlatformAuthentication)
20 |
21 | /**
22 | * Facebook Chat X-FACEBOOK-PLATFORM SASL authentication initialization.
23 | * This is a convienence init method to help configure Facebook Chat.
24 | **/
25 | - (id)initWithFacebookAppId:(NSString *)fbAppId;
26 |
27 | /**
28 | * The appId can be passed to custom authentication classes.
29 | * For example, the appId is used for Facebook Chat X-FACEBOOK-PLATFORM SASL authentication.
30 | **/
31 | @property (readwrite, copy) NSString *facebookAppId;
32 |
33 | /**
34 | * Returns whether or not the server supports X-FACEBOOK-PLATFORM authentication.
35 | *
36 | * This information is available after the stream is connected.
37 | * In other words, after the delegate has received xmppStreamDidConnect: notification.
38 | **/
39 | - (BOOL)supportsXFacebookPlatformAuthentication;
40 |
41 | /**
42 | * This method attempts to start the facebook oauth authentication process.
43 | *
44 | * This method is asynchronous.
45 | *
46 | * If there is something immediately wrong,
47 | * such as the stream is not connected or doesn't have a set appId or accessToken,
48 | * the method will return NO and set the error.
49 | * Otherwise the delegate callbacks are used to communicate auth success or failure.
50 | *
51 | * @see xmppStreamDidAuthenticate:
52 | * @see xmppStream:didNotAuthenticate:
53 | **/
54 | - (BOOL)authenticateWithFacebookAccessToken:(NSString *)accessToken error:(NSError **)errPtr;
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Authentication/X-OAuth2-Google/XMPPXOAuth2Google.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPXOAuth2Google.h
3 | // Off the Record
4 | //
5 | // Created by David Chiles on 9/13/13.
6 | // Copyright (c) 2013 Chris Ballinger. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "XMPPSASLAuthentication.h"
11 | #import "XMPPStream.h"
12 |
13 | @interface XMPPXOAuth2Google : NSObject
14 |
15 | -(id)initWithStream:(XMPPStream *)stream accessToken:(NSString *)accessToken;
16 |
17 | @end
18 |
19 |
20 |
21 | @interface XMPPStream (XMPPXOAuth2Google)
22 |
23 |
24 | - (BOOL)supportsXOAuth2GoogleAuthentication;
25 |
26 | - (BOOL)authenticateWithGoogleAccessToken:(NSString *)accessToken error:(NSError **)errPtr;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Categories/NSData+XMPP.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface NSData (XMPP)
4 |
5 | - (NSData *)xmpp_md5Digest;
6 |
7 | - (NSData *)xmpp_sha1Digest;
8 |
9 | - (NSString *)xmpp_hexStringValue;
10 |
11 | - (NSString *)xmpp_base64Encoded;
12 | - (NSData *)xmpp_base64Decoded;
13 |
14 | - (BOOL)xmpp_isJPEG;
15 | - (BOOL)xmpp_isPNG;
16 | - (NSString *)xmpp_imageType;
17 |
18 | @end
19 |
20 | #ifndef XMPP_EXCLUDE_DEPRECATED
21 |
22 | #define XMPP_DEPRECATED($message) __attribute__((deprecated($message)))
23 |
24 | @interface NSData (XMPPDeprecated)
25 | - (NSData *)md5Digest XMPP_DEPRECATED("Use -xmpp_md5Digest");
26 | - (NSData *)sha1Digest XMPP_DEPRECATED("Use -xmpp_sha1Digest");
27 | - (NSString *)hexStringValue XMPP_DEPRECATED("Use -xmpp_hexStringValue");
28 | - (NSString *)base64Encoded XMPP_DEPRECATED("Use -xmpp_base64Encoded");
29 | - (NSData *)base64Decoded XMPP_DEPRECATED("Use -xmpp_base64Decoded");
30 | @end
31 |
32 | #undef XMPP_DEPRECATED
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Categories/NSNumber+XMPP.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 |
4 | @interface NSNumber (XMPP)
5 |
6 | + (NSNumber *)xmpp_numberWithPtr:(const void *)ptr;
7 | - (id)xmpp_initWithPtr:(const void *)ptr __attribute__((objc_method_family(init)));
8 |
9 | + (BOOL)xmpp_parseString:(NSString *)str intoInt32:(int32_t *)pNum;
10 | + (BOOL)xmpp_parseString:(NSString *)str intoUInt32:(uint32_t *)pNum;
11 |
12 | + (BOOL)xmpp_parseString:(NSString *)str intoInt64:(int64_t *)pNum;
13 | + (BOOL)xmpp_parseString:(NSString *)str intoUInt64:(uint64_t *)pNum;
14 |
15 | + (BOOL)xmpp_parseString:(NSString *)str intoNSInteger:(NSInteger *)pNum;
16 | + (BOOL)xmpp_parseString:(NSString *)str intoNSUInteger:(NSUInteger *)pNum;
17 |
18 | + (UInt8)xmpp_extractUInt8FromData:(NSData *)data atOffset:(unsigned int)offset;
19 |
20 | + (UInt16)xmpp_extractUInt16FromData:(NSData *)data atOffset:(unsigned int)offset andConvertFromNetworkOrder:(BOOL)flag;
21 |
22 | + (UInt32)xmpp_extractUInt32FromData:(NSData *)data atOffset:(unsigned int)offset andConvertFromNetworkOrder:(BOOL)flag;
23 |
24 | @end
25 |
26 | #ifndef XMPP_EXCLUDE_DEPRECATED
27 |
28 | #define XMPP_DEPRECATED($message) __attribute__((deprecated($message)))
29 |
30 | @interface NSNumber (XMPPDeprecated)
31 | + (NSNumber *)numberWithPtr:(const void *)ptr XMPP_DEPRECATED("Use +xmpp_numberWithPtr:");
32 | - (id)initWithPtr:(const void *)ptr XMPP_DEPRECATED("Use -xmpp_initWithPtr:");
33 | + (BOOL)parseString:(NSString *)str intoInt32:(int32_t *)pNum XMPP_DEPRECATED("Use +xmpp_parseString:intoInt32:");
34 | + (BOOL)parseString:(NSString *)str intoUInt32:(uint32_t *)pNum XMPP_DEPRECATED("Use +xmpp_parseString:intoUInt32:");
35 | + (BOOL)parseString:(NSString *)str intoInt64:(int64_t *)pNum XMPP_DEPRECATED("Use +xmpp_parseString:intoInt64:");
36 | + (BOOL)parseString:(NSString *)str intoUInt64:(uint64_t *)pNum XMPP_DEPRECATED("Use +xmpp_parseString:intoUInt64:");
37 | + (BOOL)parseString:(NSString *)str intoNSInteger:(NSInteger *)pNum XMPP_DEPRECATED("Use +xmpp_parseString:intoNSInteger:");
38 | + (BOOL)parseString:(NSString *)str intoNSUInteger:(NSUInteger *)pNum XMPP_DEPRECATED("Use +xmpp_parseString:intoNSUInteger:");
39 | + (UInt8)extractUInt8FromData:(NSData *)data atOffset:(unsigned int)offset XMPP_DEPRECATED("Use +xmpp_extractUInt8FromData:atOffset:");
40 | + (UInt16)extractUInt16FromData:(NSData *)data atOffset:(unsigned int)offset andConvertFromNetworkOrder:(BOOL)flag XMPP_DEPRECATED("Use +xmpp_extractUInt16FromData:atOffset:andConvertFromNetworkOrder:");
41 | + (UInt32)extractUInt32FromData:(NSData *)data atOffset:(unsigned int)offset andConvertFromNetworkOrder:(BOOL)flag XMPP_DEPRECATED("Use +xmpp_extractUInt32FromData:atOffset:andConvertFromNetworkOrder:");
42 | @end
43 |
44 | #undef XMPP_DEPRECATED
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Core/XMPP.h:
--------------------------------------------------------------------------------
1 | //
2 | // Core classes
3 | //
4 |
5 | #import "XMPPJID.h"
6 | #import "XMPPStream.h"
7 | #import "XMPPElement.h"
8 | #import "XMPPIQ.h"
9 | #import "XMPPMessage.h"
10 | #import "XMPPPresence.h"
11 | #import "XMPPModule.h"
12 |
13 | //
14 | // Authentication
15 | //
16 |
17 | #import "XMPPSASLAuthentication.h"
18 | #import "XMPPCustomBinding.h"
19 | #import "XMPPDigestMD5Authentication.h"
20 | #import "XMPPSCRAMSHA1Authentication.h"
21 | #import "XMPPPlainAuthentication.h"
22 | #import "XMPPXFacebookPlatformAuthentication.h"
23 | #import "XMPPAnonymousAuthentication.h"
24 | #import "XMPPDeprecatedPlainAuthentication.h"
25 | #import "XMPPDeprecatedDigestAuthentication.h"
26 |
27 | //
28 | // Categories
29 | //
30 |
31 | #import "NSXMLElement+XMPP.h"
32 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Core/XMPPConstants.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | /**
4 | * This class is provided to house various namespaces that are reused throughout
5 | * the project. Feel free to add to the constants as you see necessary. If a
6 | * particular namespace is only applicable to a particular extension, then it
7 | * should be inside that extension rather than here.
8 | */
9 |
10 | extern NSString *const XMPPSINamespace;
11 | extern NSString *const XMPPSIProfileFileTransferNamespace;
12 | extern NSString *const XMPPFeatureNegNamespace;
13 | extern NSString *const XMPPBytestreamsNamespace;
14 | extern NSString *const XMPPIBBNamespace;
15 | extern NSString *const XMPPDiscoItemsNamespace;
16 | extern NSString *const XMPPDiscoInfoNamespace;
17 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Core/XMPPConstants.m:
--------------------------------------------------------------------------------
1 | #import "XMPPConstants.h"
2 |
3 | NSString *const XMPPSINamespace = @"http://jabber.org/protocol/si";
4 | NSString *const XMPPSIProfileFileTransferNamespace =
5 | @"http://jabber.org/protocol/si/profile/file-transfer";
6 | NSString *const XMPPFeatureNegNamespace = @"http://jabber.org/protocol/feature-neg";
7 | NSString *const XMPPBytestreamsNamespace = @"http://jabber.org/protocol/bytestreams";
8 | NSString *const XMPPIBBNamespace = @"http://jabber.org/protocol/ibb";
9 | NSString *const XMPPDiscoItemsNamespace = @"http://jabber.org/protocol/disco#items";
10 | NSString *const XMPPDiscoInfoNamespace = @"http://jabber.org/protocol/disco#info";
11 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Core/XMPPElement.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPJID.h"
3 |
4 | #if TARGET_OS_IPHONE
5 | #import "DDXML.h"
6 | #endif
7 |
8 |
9 | /**
10 | * The XMPPElement provides the base class for XMPPIQ, XMPPMessage & XMPPPresence.
11 | *
12 | * This class extends NSXMLElement.
13 | * The NSXML classes (NSXMLElement & NSXMLNode) provide a full-featured library for working with XML elements.
14 | *
15 | * On the iPhone, the KissXML library provides a drop-in replacement for Apple's NSXML classes.
16 | **/
17 |
18 | @interface XMPPElement : NSXMLElement
19 |
20 | #pragma mark Common Jabber Methods
21 |
22 | - (NSString *)elementID;
23 |
24 | - (XMPPJID *)to;
25 | - (XMPPJID *)from;
26 |
27 | - (NSString *)toStr;
28 | - (NSString *)fromStr;
29 |
30 | #pragma mark To and From Methods
31 |
32 | - (BOOL)isTo:(XMPPJID *)to;
33 | - (BOOL)isTo:(XMPPJID *)to options:(XMPPJIDCompareOptions)mask;
34 |
35 | - (BOOL)isFrom:(XMPPJID *)from;
36 | - (BOOL)isFrom:(XMPPJID *)from options:(XMPPJIDCompareOptions)mask;
37 |
38 | - (BOOL)isToOrFrom:(XMPPJID *)toOrFrom;
39 | - (BOOL)isToOrFrom:(XMPPJID *)toOrFrom options:(XMPPJIDCompareOptions)mask;
40 |
41 | - (BOOL)isTo:(XMPPJID *)to from:(XMPPJID *)from;
42 | - (BOOL)isTo:(XMPPJID *)to from:(XMPPJID *)from options:(XMPPJIDCompareOptions)mask;
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Core/XMPPJID.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | enum XMPPJIDCompareOptions
4 | {
5 | XMPPJIDCompareUser = 1, // 001
6 | XMPPJIDCompareDomain = 2, // 010
7 | XMPPJIDCompareResource = 4, // 100
8 |
9 | XMPPJIDCompareBare = 3, // 011
10 | XMPPJIDCompareFull = 7, // 111
11 | };
12 | typedef enum XMPPJIDCompareOptions XMPPJIDCompareOptions;
13 |
14 |
15 | @interface XMPPJID : NSObject
16 | {
17 | __strong NSString *user;
18 | __strong NSString *domain;
19 | __strong NSString *resource;
20 | }
21 |
22 | + (XMPPJID *)jidWithString:(NSString *)jidStr;
23 | + (XMPPJID *)jidWithString:(NSString *)jidStr resource:(NSString *)resource;
24 | + (XMPPJID *)jidWithUser:(NSString *)user domain:(NSString *)domain resource:(NSString *)resource;
25 |
26 | @property (strong, readonly) NSString *user;
27 | @property (strong, readonly) NSString *domain;
28 | @property (strong, readonly) NSString *resource;
29 |
30 | /**
31 | * Terminology (from RFC 6120):
32 | *
33 | * The term "bare JID" refers to an XMPP address of the form (for an account at a server)
34 | * or of the form (for a server).
35 | *
36 | * The term "full JID" refers to an XMPP address of the form
37 | * (for a particular authorized client or device associated with an account)
38 | * or of the form (for a particular resource or script associated with a server).
39 | *
40 | * Thus a bareJID is one that does not have a resource.
41 | * And a fullJID is one that does have a resource.
42 | *
43 | * For convenience, there are also methods that that check for a user component as well.
44 | **/
45 |
46 | - (XMPPJID *)bareJID;
47 | - (XMPPJID *)domainJID;
48 |
49 | - (NSString *)bare;
50 | - (NSString *)full;
51 |
52 | - (BOOL)isBare;
53 | - (BOOL)isBareWithUser;
54 |
55 | - (BOOL)isFull;
56 | - (BOOL)isFullWithUser;
57 |
58 | /**
59 | * A server JID does not have a user component.
60 | **/
61 | - (BOOL)isServer;
62 |
63 | /**
64 | * Returns a new jid with the given resource.
65 | **/
66 | - (XMPPJID *)jidWithNewResource:(NSString *)resource;
67 |
68 | /**
69 | * When you know both objects are JIDs, this method is a faster way to check equality than isEqual:.
70 | **/
71 | - (BOOL)isEqualToJID:(XMPPJID *)aJID;
72 | - (BOOL)isEqualToJID:(XMPPJID *)aJID options:(XMPPJIDCompareOptions)mask;
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Core/XMPPMessage.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPElement.h"
3 |
4 | /**
5 | * The XMPPMessage class represents a element.
6 | * It extends XMPPElement, which in turn extends NSXMLElement.
7 | * All elements that go in and out of the
8 | * xmpp stream will automatically be converted to XMPPMessage objects.
9 | *
10 | * This class exists to provide developers an easy way to add functionality to message processing.
11 | * Simply add your own category to XMPPMessage to extend it with your own custom methods.
12 | **/
13 |
14 | @interface XMPPMessage : XMPPElement
15 |
16 | // Converts an NSXMLElement to an XMPPMessage element in place (no memory allocations or copying)
17 | + (XMPPMessage *)messageFromElement:(NSXMLElement *)element;
18 |
19 | + (XMPPMessage *)message;
20 | + (XMPPMessage *)messageWithType:(NSString *)type;
21 | + (XMPPMessage *)messageWithType:(NSString *)type to:(XMPPJID *)to;
22 | + (XMPPMessage *)messageWithType:(NSString *)type to:(XMPPJID *)jid elementID:(NSString *)eid;
23 | + (XMPPMessage *)messageWithType:(NSString *)type to:(XMPPJID *)jid elementID:(NSString *)eid child:(NSXMLElement *)childElement;
24 | + (XMPPMessage *)messageWithType:(NSString *)type elementID:(NSString *)eid;
25 | + (XMPPMessage *)messageWithType:(NSString *)type elementID:(NSString *)eid child:(NSXMLElement *)childElement;
26 | + (XMPPMessage *)messageWithType:(NSString *)type child:(NSXMLElement *)childElement;
27 |
28 | - (id)init;
29 | - (id)initWithType:(NSString *)type;
30 | - (id)initWithType:(NSString *)type to:(XMPPJID *)to;
31 | - (id)initWithType:(NSString *)type to:(XMPPJID *)jid elementID:(NSString *)eid;
32 | - (id)initWithType:(NSString *)type to:(XMPPJID *)jid elementID:(NSString *)eid child:(NSXMLElement *)childElement;
33 | - (id)initWithType:(NSString *)type elementID:(NSString *)eid;
34 | - (id)initWithType:(NSString *)type elementID:(NSString *)eid child:(NSXMLElement *)childElement;
35 | - (id)initWithType:(NSString *)type child:(NSXMLElement *)childElement;
36 |
37 | - (NSString *)type;
38 | - (NSString *)subject;
39 | - (NSString *)body;
40 | - (NSString *)bodyForLanguage:(NSString *)language;
41 | - (NSString *)thread;
42 |
43 | - (void)addSubject:(NSString *)subject;
44 | - (void)addBody:(NSString *)body;
45 | - (void)addBody:(NSString *)body withLanguage:(NSString *)language;
46 | - (void)addThread:(NSString *)thread;
47 |
48 | - (BOOL)isChatMessage;
49 | - (BOOL)isChatMessageWithBody;
50 | - (BOOL)isErrorMessage;
51 | - (BOOL)isMessageWithBody;
52 |
53 | - (NSError *)errorMessage;
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Core/XMPPModule.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "GCDMulticastDelegate.h"
3 |
4 | @class XMPPStream;
5 |
6 | /**
7 | * XMPPModule is the base class that all extensions/modules inherit.
8 | * They automatically get:
9 | *
10 | * - A dispatch queue.
11 | * - A multicast delegate that automatically invokes added delegates.
12 | *
13 | * The module also automatically registers/unregisters itself with the
14 | * xmpp stream during the activate/deactive methods.
15 | **/
16 | @interface XMPPModule : NSObject
17 | {
18 | XMPPStream *xmppStream;
19 |
20 | dispatch_queue_t moduleQueue;
21 | void *moduleQueueTag;
22 |
23 | id multicastDelegate;
24 | }
25 |
26 | @property (readonly) dispatch_queue_t moduleQueue;
27 | @property (readonly) void *moduleQueueTag;
28 |
29 | @property (strong, readonly) XMPPStream *xmppStream;
30 |
31 | - (id)init;
32 | - (id)initWithDispatchQueue:(dispatch_queue_t)queue;
33 |
34 | - (BOOL)activate:(XMPPStream *)aXmppStream;
35 | - (void)deactivate;
36 |
37 | - (void)addDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue;
38 | - (void)removeDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue;
39 | - (void)removeDelegate:(id)delegate;
40 |
41 | - (NSString *)moduleName;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Core/XMPPParser.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #if TARGET_OS_IPHONE
4 | #import "DDXML.h"
5 | #endif
6 |
7 |
8 | @interface XMPPParser : NSObject
9 |
10 | - (id)initWithDelegate:(id)delegate delegateQueue:(dispatch_queue_t)dq;
11 | - (id)initWithDelegate:(id)delegate delegateQueue:(dispatch_queue_t)dq parserQueue:(dispatch_queue_t)pq;
12 |
13 | - (void)setDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue;
14 |
15 | /**
16 | * Asynchronously parses the given data.
17 | * The delegate methods will be dispatch_async'd as events occur.
18 | **/
19 | - (void)parseData:(NSData *)data;
20 |
21 | @end
22 |
23 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
24 | #pragma mark -
25 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
26 |
27 | @protocol XMPPParserDelegate
28 | @optional
29 |
30 | - (void)xmppParser:(XMPPParser *)sender didReadRoot:(NSXMLElement *)root;
31 |
32 | - (void)xmppParser:(XMPPParser *)sender didReadElement:(NSXMLElement *)element;
33 |
34 | - (void)xmppParserDidEnd:(XMPPParser *)sender;
35 |
36 | - (void)xmppParser:(XMPPParser *)sender didFail:(NSError *)error;
37 |
38 | - (void)xmppParserDidParseData:(XMPPParser *)sender;
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Core/XMPPPresence.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPElement.h"
3 |
4 | /**
5 | * The XMPPPresence class represents a element.
6 | * It extends XMPPElement, which in turn extends NSXMLElement.
7 | * All elements that go in and out of the
8 | * xmpp stream will automatically be converted to XMPPPresence objects.
9 | *
10 | * This class exists to provide developers an easy way to add functionality to presence processing.
11 | * Simply add your own category to XMPPPresence to extend it with your own custom methods.
12 | **/
13 |
14 | @interface XMPPPresence : XMPPElement
15 |
16 | // Converts an NSXMLElement to an XMPPPresence element in place (no memory allocations or copying)
17 | + (XMPPPresence *)presenceFromElement:(NSXMLElement *)element;
18 |
19 | + (XMPPPresence *)presence;
20 | + (XMPPPresence *)presenceWithType:(NSString *)type;
21 | + (XMPPPresence *)presenceWithType:(NSString *)type to:(XMPPJID *)to;
22 |
23 | - (id)init;
24 | - (id)initWithType:(NSString *)type;
25 | - (id)initWithType:(NSString *)type to:(XMPPJID *)to;
26 |
27 | - (NSString *)type;
28 |
29 | - (NSString *)show;
30 | - (NSString *)status;
31 |
32 | - (int)priority;
33 |
34 | - (int)intShow;
35 |
36 | - (BOOL)isErrorPresence;
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/BandwidthMonitor/XMPPBandwidthMonitor.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Simple XMPP module that tracks average bandwidth of the xmpp stream.
3 | *
4 | * For now, this is a really simple module.
5 | * But perhaps in the future, as developers adapt this module,
6 | * they will open source their additions and improvements.
7 | **/
8 |
9 | #import
10 | #import "XMPP.h"
11 |
12 | #define _XMPP_BANDWIDTH_MONITOR_H
13 |
14 | @interface XMPPBandwidthMonitor : XMPPModule
15 |
16 | @property (readonly) double outgoingBandwidth;
17 | @property (readonly) double incomingBandwidth;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/FileTransfer/XMPPFileTransfer.m:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Jonathon Staff on 10/21/14.
3 | // Copyright (c) 2014 nplexity, LLC. All rights reserved.
4 | //
5 |
6 | #import "XMPPFileTransfer.h"
7 |
8 |
9 | @implementation XMPPFileTransfer
10 |
11 | @end
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/GoogleSharedStatus/XMPPGoogleSharedStatus.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPModule.h"
3 |
4 | extern NSString *const XMPPGoogleSharedStatusShow;
5 | extern NSString *const XMPPGoogleSharedStatusInvisible;
6 | extern NSString *const XMPPGoogleSharedStatusStatus;
7 |
8 | extern NSString *const XMPPGoogleSharedStatusShowAvailable;
9 | extern NSString *const XMPPGoogleSharedStatusShowBusy;
10 | extern NSString *const XMPPGoogleSharedStatusShowIdle;
11 |
12 | @protocol XMPPGoogleSharedStatusDelegate;
13 |
14 |
15 | #define _XMPP_GOOGLE_SHARED_STATUS_H
16 |
17 | @interface XMPPGoogleSharedStatus : XMPPModule
18 |
19 | @property (nonatomic, assign) BOOL sharedStatusSupported;
20 | @property (nonatomic, strong) NSDictionary *sharedStatus;
21 |
22 | // Determines if the user is idle based on last received HID
23 | // event, and sends the presence as away, if the user is idle.
24 | @property (nonatomic, assign) BOOL assumeIdleUpdateResponsibility;
25 |
26 | @property (nonatomic, strong) NSString *status;
27 | @property (nonatomic, strong) NSString *show;
28 | @property (nonatomic, assign) BOOL invisible;
29 |
30 | // Convenience auto-updater for presence status.
31 | // Does not use XMPPGoogleSharedStatus.
32 | @property (nonatomic, copy) NSString *statusMessage;
33 | @property (nonatomic, copy) NSString *statusAvailability;
34 |
35 | - (void)updateSharedStatus:(NSString *)status
36 | show:(NSString *)show
37 | invisible:(BOOL)invisible;
38 |
39 | - (void)refreshSharedStatus;
40 |
41 | @end
42 |
43 | @protocol XMPPGoogleSharedStatusDelegate
44 |
45 | @optional
46 |
47 | // This delegate method is called when the server updates the shared
48 | // status module with new status information, or upon manual refresh.
49 | - (void)xmppGoogleSharedStatus:(XMPPGoogleSharedStatus *)sender didReceiveUpdatedStatus:(NSDictionary *)sharedStatus;
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/Roster/CoreDataStorage/XMPPGroupCoreDataStorageObject.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPGroupCoreDataStorageObject.h
3 | //
4 | // Created by Eric Chamberlain on 3/20/11.
5 | // Copyright (c) 2011 RF.com. All rights reserved.
6 | //
7 |
8 | #import
9 | #import
10 |
11 |
12 | @class XMPPUserCoreDataStorageObject;
13 |
14 |
15 | @interface XMPPGroupCoreDataStorageObject : NSManagedObject {
16 | @private
17 | }
18 |
19 | @property (nonatomic, strong) NSString * name;
20 | @property (nonatomic, strong) NSSet* users;
21 |
22 | + (void)clearEmptyGroupsInManagedObjectContext:(NSManagedObjectContext *)moc;
23 |
24 | + (id)fetchOrInsertGroupName:(NSString *)groupName inManagedObjectContext:(NSManagedObjectContext *)moc;
25 |
26 | + (id)insertGroupName:(NSString *)groupName inManagedObjectContext:(NSManagedObjectContext *)moc;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/Roster/CoreDataStorage/XMPPResourceCoreDataStorageObject.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "XMPPResource.h"
4 |
5 | @class XMPPStream;
6 | @class XMPPPresence;
7 | @class XMPPUserCoreDataStorageObject;
8 |
9 |
10 | @interface XMPPResourceCoreDataStorageObject : NSManagedObject
11 |
12 | @property (nonatomic, strong) XMPPJID *jid;
13 | @property (nonatomic, strong) XMPPPresence *presence;
14 |
15 | @property (nonatomic, assign) int priority;
16 | @property (nonatomic, assign) int intShow;
17 |
18 | @property (nonatomic, strong) NSString * jidStr;
19 | @property (nonatomic, strong) NSString * presenceStr;
20 |
21 | @property (nonatomic, strong) NSString * streamBareJidStr;
22 |
23 | @property (nonatomic, strong) NSString * type;
24 | @property (nonatomic, strong) NSString * show;
25 | @property (nonatomic, strong) NSString * status;
26 |
27 | @property (nonatomic, strong) NSDate * presenceDate;
28 |
29 | @property (nonatomic, strong) NSNumber * priorityNum;
30 | @property (nonatomic, strong) NSNumber * showNum;
31 |
32 | @property (nonatomic, strong) XMPPUserCoreDataStorageObject * user;
33 |
34 | + (id)insertInManagedObjectContext:(NSManagedObjectContext *)moc
35 | withPresence:(XMPPPresence *)presence
36 | streamBareJidStr:(NSString *)streamBareJidStr;
37 |
38 | - (void)updateWithPresence:(XMPPPresence *)presence;
39 |
40 | - (NSComparisonResult)compare:(id )another;
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/Roster/CoreDataStorage/XMPPRoster.xcdatamodel/elements:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/XMPP/Extensions/Roster/CoreDataStorage/XMPPRoster.xcdatamodel/elements
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/Roster/CoreDataStorage/XMPPRoster.xcdatamodel/layout:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/XMPP/Extensions/Roster/CoreDataStorage/XMPPRoster.xcdatamodel/layout
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/Roster/MemoryStorage/XMPPResourceMemoryStorageObject.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPResource.h"
3 |
4 | @class XMPPJID;
5 | @class XMPPIQ;
6 | @class XMPPPresence;
7 |
8 |
9 | @interface XMPPResourceMemoryStorageObject : NSObject
10 | {
11 | XMPPJID *jid;
12 | XMPPPresence *presence;
13 |
14 | NSDate *presenceDate;
15 | }
16 |
17 | /* From the XMPPResource protocol
18 |
19 | - (XMPPJID *)jid;
20 | - (XMPPPresence *)presence;
21 |
22 | - (NSDate *)presenceDate;
23 |
24 | - (NSComparisonResult)compare:(id )another;
25 |
26 | */
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/Roster/MemoryStorage/XMPPRosterMemoryStoragePrivate.h:
--------------------------------------------------------------------------------
1 | #import "XMPPUserMemoryStorageObject.h"
2 | #import "XMPPResourceMemoryStorageObject.h"
3 |
4 | /**
5 | * The following methods are designed to be invoked ONLY from
6 | * within the XMPPRosterMemoryStorage implementation.
7 | *
8 | * Warning: XMPPUserMemoryStorage and XMPPResourceMemoryStorage are not explicitly thread-safe.
9 | * Only copies that are no longer being actively
10 | * altered by the XMPPRosterMemoryStorage class should be considered read-only and therefore thread-safe.
11 | **/
12 |
13 | #define XMPP_USER_NO_CHANGE 0
14 | #define XMPP_USER_ADDED_RESOURCE 1
15 | #define XMPP_USER_UPDATED_RESOURCE 2
16 | #define XMPP_USER_REMOVED_RESOURCE 3
17 |
18 |
19 | @interface XMPPUserMemoryStorageObject ()
20 |
21 | - (void)commonInit;
22 |
23 | - (id)initWithJID:(XMPPJID *)aJid;
24 | - (id)initWithItem:(NSXMLElement *)item;
25 |
26 | - (void)updateWithItem:(NSXMLElement *)item;
27 |
28 | - (int)updateWithPresence:(XMPPPresence *)presence
29 | resourceClass:(Class)resourceClass
30 | andGetResource:(XMPPResourceMemoryStorageObject **)resourcePtr;
31 |
32 | - (void)clearAllResources;
33 |
34 | #if TARGET_OS_IPHONE
35 | @property (nonatomic, strong, readwrite) UIImage *photo;
36 | #else
37 | @property (nonatomic, strong, readwrite) NSImage *photo;
38 | #endif
39 |
40 | @end
41 |
42 | @interface XMPPResourceMemoryStorageObject ()
43 |
44 | - (id)initWithPresence:(XMPPPresence *)aPresence;
45 |
46 | - (void)updateWithPresence:(XMPPPresence *)presence;
47 |
48 | - (XMPPPresence *)presence;
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/Roster/MemoryStorage/XMPPUserMemoryStorageObject.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPUser.h"
3 | #import "XMPP.h"
4 |
5 | #if !TARGET_OS_IPHONE
6 | #import
7 | #endif
8 |
9 | @class XMPPResourceMemoryStorageObject;
10 |
11 |
12 | @interface XMPPUserMemoryStorageObject : NSObject
13 | {
14 | XMPPJID *jid;
15 | NSMutableDictionary *itemAttributes;
16 | NSMutableArray *groups;
17 |
18 | NSMutableDictionary *resources;
19 | XMPPResourceMemoryStorageObject *primaryResource;
20 |
21 | #if TARGET_OS_IPHONE
22 | UIImage *photo;
23 | #else
24 | NSImage *photo;
25 | #endif
26 | }
27 |
28 | /* From the XMPPUser protocol
29 |
30 | - (XMPPJID *)jid;
31 | - (NSString *)nickname;
32 |
33 | - (BOOL)isOnline;
34 | - (BOOL)isPendingApproval;
35 |
36 | - (id )primaryResource;
37 | - (id )resourceForJID:(XMPPJID *)jid;
38 |
39 | - (NSArray *)allResources;
40 |
41 | */
42 |
43 | - (NSString *)subscription;
44 |
45 | - (NSString *)ask;
46 |
47 | /**
48 | * Simple convenience method.
49 | * If a nickname exists for the user, the nickname is returned.
50 | * Otherwise the jid is returned (as a string).
51 | **/
52 | - (NSString *)displayName;
53 |
54 | /**
55 | * An array of Group Names.
56 | **/
57 | - (NSArray *)groups;
58 |
59 | /**
60 | * If XMPPvCardAvatarModule is included in the framework, the XMPPRoster will automatically integrate with it,
61 | * and we'll save the the user photos after they've been downloaded.
62 | **/
63 | #if TARGET_OS_IPHONE
64 | @property (nonatomic, strong, readonly) UIImage *photo;
65 | #else
66 | @property (nonatomic, strong, readonly) NSImage *photo;
67 | #endif
68 |
69 | /**
70 | * Simple comparison methods.
71 | **/
72 |
73 | - (NSComparisonResult)compareByName:(XMPPUserMemoryStorageObject *)another;
74 | - (NSComparisonResult)compareByName:(XMPPUserMemoryStorageObject *)another options:(NSStringCompareOptions)mask;
75 |
76 | - (NSComparisonResult)compareByAvailabilityName:(XMPPUserMemoryStorageObject *)another;
77 | - (NSComparisonResult)compareByAvailabilityName:(XMPPUserMemoryStorageObject *)another
78 | options:(NSStringCompareOptions)mask;
79 |
80 | @end
81 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/Roster/XMPPResource.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPP.h"
3 |
4 |
5 | @protocol XMPPResource
6 | @required
7 |
8 | - (XMPPJID *)jid;
9 | - (XMPPPresence *)presence;
10 |
11 | - (NSDate *)presenceDate;
12 |
13 | - (NSComparisonResult)compare:(id )another;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/Roster/XMPPRosterPrivate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPRoster.h"
3 |
4 | @interface XMPPRoster (PrivateInternalAPI)
5 |
6 | /**
7 | * XMPPRosterStorage classes may optionally use the same delegate(s) as their parent XMPPRoster.
8 | * This method allows such storage classes to access the delegate(s).
9 | *
10 | * Note: If the storage class operates on a different queue than its parent,
11 | * it MUST dispatch all calls to the multicastDelegate onto its parent's queue.
12 | * The parent's dispatch queue is passed in the configureWithParent:queue: method.
13 | **/
14 | - (GCDMulticastDelegate *)multicastDelegate;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/Roster/XMPPUser.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPP.h"
3 |
4 | @protocol XMPPResource;
5 |
6 |
7 | @protocol XMPPUser
8 | @required
9 |
10 | - (XMPPJID *)jid;
11 | - (NSString *)nickname;
12 |
13 | - (BOOL)isOnline;
14 | - (BOOL)isPendingApproval;
15 |
16 | - (id )primaryResource;
17 | - (id )resourceForJID:(XMPPJID *)jid;
18 |
19 | - (NSArray *)allResources;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/SystemInputActivityMonitor/XMPPSystemInputActivityMonitor.h:
--------------------------------------------------------------------------------
1 | #import "XMPPModule.h"
2 |
3 | extern const NSTimeInterval XMPPSystemInputActivityMonitorInactivityTimeIntervalNone;
4 |
5 | #define _XMPP_SYSTEM_INPUT_ACTIVITY_MONITOR_H
6 |
7 | /**
8 | * XMPPSystemInputActivityMonitor is used to keep track of system input activity.
9 | * This module could be used to add features such as "auto away" when the user is inactive for 5 mins.
10 | **/
11 |
12 | @interface XMPPSystemInputActivityMonitor : XMPPModule
13 | {
14 | dispatch_source_t timer;
15 |
16 | BOOL active;
17 | NSDate *lastActivityDate;
18 | NSTimeInterval inactivityTimeInterval;
19 | }
20 |
21 | /**
22 | * Returns wether the system is active based on the lastActivityDate and inactivityTimeInterval.
23 | **/
24 | @property (assign, getter = isActive, readonly) BOOL active;
25 |
26 | /**
27 | * The last time any input activity was detected.
28 | **/
29 | @property (assign, readonly) NSDate *lastActivityDate;
30 |
31 | /**
32 | * The minimum time interval after the last input activity, that assumes the system is idle.
33 | *
34 | * To disable activity checking set this value to XMPPSystemInputActivityMonitorInactivityTimeIntervalNone
35 | * If set to XMPPSystemInputActivityMonitorInactivityTimeIntervalNone none of delegate methods will be called.
36 | * Setting this value doesn't cause the delegate methods to be called immediately.
37 | *
38 | * Default 300 Seconds
39 | **/
40 | @property (assign) NSTimeInterval inactivityTimeInterval;
41 |
42 | @end
43 |
44 | @protocol XMPPSystemInputActivityMonitorDelegate
45 |
46 | /**
47 | * The system did become active after being inactive.
48 | **/
49 | - (void)xmppSystemInputActivityMonitorDidBecomeActive:(XMPPSystemInputActivityMonitor *)xmppSystemInputActivityMonitor;
50 |
51 | /**
52 | * The system did become inactive after being active.
53 | **/
54 | - (void)xmppSystemInputActivityMonitorDidBecomeInactive:(XMPPSystemInputActivityMonitor *)xmppSystemInputActivityMonitor;
55 |
56 | @end
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0009/XMPPIQ+JabberRPC.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPIQ+JabberRPC.h
3 | // XEP-0009
4 | //
5 | // Created by Eric Chamberlain on 5/16/10.
6 | //
7 |
8 | #import
9 |
10 | #import "XMPPIQ.h"
11 |
12 |
13 | @interface XMPPIQ(JabberRPC)
14 |
15 | /**
16 | * Creates and returns a new autoreleased XMPPIQ.
17 | * This is the only method you normally need to call.
18 | **/
19 | + (XMPPIQ *)rpcTo:(XMPPJID *)jid methodName:(NSString *)method parameters:(NSArray *)parameters;
20 |
21 | #pragma mark -
22 | #pragma mark Element helper methods
23 |
24 | // returns a Jabber-RPC query elelement
25 | //
26 | +(NSXMLElement *)elementRpcQuery;
27 |
28 | // returns a Jabber-RPC methodCall element
29 | //
30 | +(NSXMLElement *)elementMethodCall;
31 |
32 | // returns a Jabber-RPC methodName element
33 | // method
34 | +(NSXMLElement *)elementMethodName:(NSString *)method;
35 |
36 | // returns a Jabber-RPC params element
37 | //
38 | +(NSXMLElement *)elementParams;
39 |
40 | #pragma mark -
41 | #pragma mark Disco elements
42 |
43 | // returns the Disco query identity element
44 | //
45 | +(NSXMLElement *)elementRpcIdentity;
46 |
47 | // returns the Disco query feature element
48 | //
49 | +(NSXMLElement *)elementRpcFeature;
50 |
51 | #pragma mark -
52 | #pragma mark Conversion methods
53 |
54 | // encode any object into JabberRPC formatted element
55 | // this method calls the others
56 | +(NSXMLElement *)paramElementFromObject:(id)object;
57 |
58 | +(NSXMLElement *)valueElementFromObject:(id)object;
59 |
60 | +(NSXMLElement *)valueElementFromArray:(NSArray *)array;
61 | +(NSXMLElement *)valueElementFromDictionary:(NSDictionary *)dictionary;
62 |
63 | +(NSXMLElement *)valueElementFromBoolean:(CFBooleanRef)boolean;
64 | +(NSXMLElement *)valueElementFromNumber:(NSNumber *)number;
65 | +(NSXMLElement *)valueElementFromString:(NSString *)string;
66 | +(NSXMLElement *)valueElementFromDate:(NSDate *)date;
67 | +(NSXMLElement *)valueElementFromData:(NSData *)data;
68 |
69 | +(NSXMLElement *)valueElementFromElementWithName:(NSString *)elementName value:(NSString *)value;
70 |
71 |
72 | #pragma mark Wrapper methods
73 |
74 | +(NSXMLElement *)wrapElement:(NSString *)elementName aroundElement:(NSXMLElement *)element;
75 | +(NSXMLElement *)wrapValueElementAroundElement:(NSXMLElement *)element;
76 |
77 | @end
78 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0009/XMPPIQ+JabberRPCResonse.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPIQ+JabberRPCResonse.h
3 | // XEP-0009
4 | //
5 | // Created by Eric Chamberlain on 5/25/10.
6 | //
7 |
8 | #import "XMPPIQ.h"
9 |
10 | typedef enum {
11 | JabberRPCElementTypeArray,
12 | JabberRPCElementTypeDictionary,
13 | JabberRPCElementTypeMember,
14 | JabberRPCElementTypeName,
15 | JabberRPCElementTypeInteger,
16 | JabberRPCElementTypeDouble,
17 | JabberRPCElementTypeBoolean,
18 | JabberRPCElementTypeString,
19 | JabberRPCElementTypeDate,
20 | JabberRPCElementTypeData
21 | } JabberRPCElementType;
22 |
23 |
24 | @interface XMPPIQ(JabberRPCResonse)
25 |
26 | -(NSXMLElement *)methodResponseElement;
27 |
28 | // is this a Jabber RPC method response
29 | -(BOOL)isMethodResponse;
30 |
31 | -(BOOL)isFault;
32 |
33 | -(BOOL)isJabberRPC;
34 |
35 | -(id)methodResponse:(NSError **)error;
36 |
37 | -(id)objectFromElement:(NSXMLElement *)param;
38 |
39 |
40 | #pragma mark -
41 |
42 | -(NSArray *)parseArray:(NSXMLElement *)arrayElement;
43 |
44 | -(NSDictionary *)parseStruct:(NSXMLElement *)structElement;
45 |
46 | -(NSDictionary *)parseMember:(NSXMLElement *)memberElement;
47 |
48 | #pragma mark -
49 |
50 | - (NSDate *)parseDateString: (NSString *)dateString withFormat: (NSString *)format;
51 |
52 | #pragma mark -
53 |
54 | - (NSNumber *)parseInteger: (NSString *)value;
55 |
56 | - (NSNumber *)parseDouble: (NSString *)value;
57 |
58 | - (NSNumber *)parseBoolean: (NSString *)value;
59 |
60 | - (NSString *)parseString: (NSString *)value;
61 |
62 | - (NSDate *)parseDate: (NSString *)value;
63 |
64 | - (NSData *)parseData: (NSString *)value;
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0009/XMPPJabberRPCModule.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPJabberRPCModule.h
3 | // XEP-0009
4 | //
5 | // Originally created by Eric Chamberlain on 5/16/10.
6 | //
7 |
8 | #import
9 | #import "XMPPModule.h"
10 |
11 | #define _XMPP_JABBER_RPC_MODULE_H
12 |
13 | extern NSString *const XMPPJabberRPCErrorDomain;
14 |
15 | @class XMPPJID;
16 | @class XMPPStream;
17 | @class XMPPIQ;
18 | @protocol XMPPJabberRPCModuleDelegate;
19 |
20 |
21 | @interface XMPPJabberRPCModule : XMPPModule
22 | {
23 | NSMutableDictionary *rpcIDs;
24 | NSTimeInterval defaultTimeout;
25 | }
26 |
27 | @property (nonatomic, assign) NSTimeInterval defaultTimeout;
28 |
29 | - (NSString *)sendRpcIQ:(XMPPIQ *)iq;
30 | - (NSString *)sendRpcIQ:(XMPPIQ *)iq withTimeout:(NSTimeInterval)timeout;
31 |
32 | // caller knows best when a request has timed out
33 | // it should remove the rpcID, on timeout.
34 | - (void)timeoutRemoveRpcID:(NSString *)rpcID;
35 |
36 | @end
37 |
38 |
39 | @protocol XMPPJabberRPCModuleDelegate
40 | @optional
41 |
42 | // sent when transport error is received
43 | -(void)jabberRPC:(XMPPJabberRPCModule *)sender elementID:(NSString *)elementID didReceiveError:(NSError *)error;
44 |
45 | // sent when a methodResponse comes back
46 | -(void)jabberRPC:(XMPPJabberRPCModule *)sender elementID:(NSString *)elementID didReceiveMethodResponse:(id)response;
47 |
48 | // sent when a Jabber-RPC server request is received
49 | -(void)jabberRPC:(XMPPJabberRPCModule *)sender didReceiveSetIQ:(XMPPIQ *)iq;
50 | @end
51 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/CoreDataStorage/XMPPRoom.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | XMPPRoom.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/CoreDataStorage/XMPPRoomMessageCoreDataStorageObject.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import "XMPP.h"
5 | #import "XMPPRoom.h"
6 |
7 |
8 | @interface XMPPRoomMessageCoreDataStorageObject : NSManagedObject
9 |
10 | /**
11 | * The properties below are documented in the XMPPRoomMessage protocol.
12 | **/
13 |
14 | @property (nonatomic, retain) XMPPMessage * message; // Transient (proper type, not on disk)
15 | @property (nonatomic, retain) NSString * messageStr; // Shadow (binary data, written to disk)
16 |
17 | @property (nonatomic, strong) XMPPJID * roomJID; // Transient (proper type, not on disk)
18 | @property (nonatomic, strong) NSString * roomJIDStr; // Shadow (binary data, written to disk)
19 |
20 | @property (nonatomic, retain) XMPPJID * jid; // Transient (proper type, not on disk)
21 | @property (nonatomic, retain) NSString * jidStr; // Shadow (binary data, written to disk)
22 |
23 | @property (nonatomic, retain) NSString * nickname;
24 | @property (nonatomic, retain) NSString * body;
25 |
26 | @property (nonatomic, retain) NSDate * localTimestamp;
27 | @property (nonatomic, strong) NSDate * remoteTimestamp;
28 |
29 | @property (nonatomic, assign) BOOL isFromMe;
30 | @property (nonatomic, strong) NSNumber * fromMe;
31 |
32 | /**
33 | * The 'type' property can be used to inject event messages.
34 | * For example: "JohnDoe entered the room".
35 | *
36 | * You can define your own types to suit your needs.
37 | * All normal messages will have a type of zero.
38 | **/
39 | @property (nonatomic, strong) NSNumber * type;
40 |
41 | /**
42 | * If a single instance of XMPPRoomCoreDataStorage is shared between multiple xmppStream's,
43 | * this may be needed to distinguish between the streams.
44 | **/
45 | @property (nonatomic, strong) NSString *streamBareJidStr;
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/CoreDataStorage/XMPPRoomOccupantCoreDataStorageObject.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import "XMPP.h"
5 | #import "XMPPRoom.h"
6 |
7 |
8 | @interface XMPPRoomOccupantCoreDataStorageObject : NSManagedObject
9 |
10 | /**
11 | * The properties below are documented in the XMPPRoomOccupant protocol.
12 | **/
13 |
14 | @property (nonatomic, strong) XMPPPresence * presence; // Transient (proper type, not on disk)
15 | @property (nonatomic, strong) NSString * presenceStr; // Shadow (binary data, written to disk)
16 |
17 | @property (nonatomic, strong) XMPPJID * roomJID; // Transient (proper type, not on disk)
18 | @property (nonatomic, strong) NSString * roomJIDStr; // Shadow (binary data, written to disk)
19 |
20 | @property (nonatomic, strong) XMPPJID * jid; // Transient (proper type, not on disk)
21 | @property (nonatomic, strong) NSString * jidStr; // Shadow (binary data, written to disk)
22 |
23 | @property (nonatomic, strong) NSString * nickname;
24 |
25 | @property (nonatomic, strong) NSString * role;
26 | @property (nonatomic, strong) NSString * affiliation;
27 |
28 | @property (nonatomic, strong) XMPPJID * realJID; // Transient (proper type, not on disk)
29 | @property (nonatomic, strong) NSString * realJIDStr; // Shadow (binary data, written to disk)
30 |
31 | @property (nonatomic, strong) NSDate * createdAt;
32 |
33 | /**
34 | * If a single instance of XMPPRoomCoreDataStorage is shared between multiple xmppStream's,
35 | * this may be needed to distinguish between the streams.
36 | **/
37 | @property (nonatomic, strong) NSString * streamBareJidStr;
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/HybridStorage/XMPPRoomHybrid.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | XMPPRoomHybrid.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/HybridStorage/XMPPRoomHybrid.xcdatamodeld/XMPPRoomHybrid.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/HybridStorage/XMPPRoomMessageHybridCoreDataStorageObject.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import "XMPP.h"
5 | #import "XMPPRoom.h"
6 |
7 |
8 | @interface XMPPRoomMessageHybridCoreDataStorageObject : NSManagedObject
9 |
10 | /**
11 | * The properties below are documented in the XMPPRoomMessage protocol.
12 | **/
13 |
14 | @property (nonatomic, retain) XMPPMessage * message; // Transient (proper type, not on disk)
15 | @property (nonatomic, retain) NSString * messageStr; // Shadow (binary data, written to disk)
16 |
17 | @property (nonatomic, strong) XMPPJID * roomJID; // Transient (proper type, not on disk)
18 | @property (nonatomic, strong) NSString * roomJIDStr; // Shadow (binary data, written to disk)
19 |
20 | @property (nonatomic, retain) XMPPJID * jid; // Transient (proper type, not on disk)
21 | @property (nonatomic, retain) NSString * jidStr; // Shadow (binary data, written to disk)
22 |
23 | @property (nonatomic, retain) NSString * nickname;
24 | @property (nonatomic, retain) NSString * body;
25 |
26 | @property (nonatomic, retain) NSDate * localTimestamp;
27 | @property (nonatomic, strong) NSDate * remoteTimestamp;
28 |
29 | @property (nonatomic, assign) BOOL isFromMe;
30 | @property (nonatomic, strong) NSNumber * fromMe;
31 |
32 | /**
33 | * The 'type' property can be used to inject event messages.
34 | * For example: "JohnDoe entered the room".
35 | *
36 | * You can define your own types to suit your needs.
37 | * All normal messages will have a type of zero.
38 | **/
39 | @property (nonatomic, strong) NSNumber * type;
40 |
41 | /**
42 | * If a single instance of XMPPRoomHybridStorage is shared between multiple xmppStream's,
43 | * this may be needed to distinguish between the streams.
44 | **/
45 | @property (nonatomic, strong) NSString *streamBareJidStr;
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/HybridStorage/XMPPRoomOccupantHybridMemoryStorageObject.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPRoom.h"
3 | #import "XMPPRoomOccupant.h"
4 |
5 |
6 | @interface XMPPRoomOccupantHybridMemoryStorageObject : NSObject
7 |
8 | - (id)initWithPresence:(XMPPPresence *)presence streamFullJid:(XMPPJID *)streamFullJid;
9 | - (void)updateWithPresence:(XMPPPresence *)presence;
10 |
11 | /**
12 | * The properties below are documented in the XMPPRoomOccupant protocol.
13 | **/
14 |
15 | @property (readonly) XMPPPresence *presence;
16 |
17 | @property (readonly) XMPPJID * jid;
18 | @property (readonly) XMPPJID * roomJID;
19 | @property (readonly) NSString * nickname;
20 |
21 | @property (readonly) NSString * role;
22 | @property (readonly) NSString * affiliation;
23 | @property (readonly) XMPPJID * realJID;
24 |
25 | @property (readonly) NSDate * createdAt;
26 |
27 | /**
28 | * Since XMPPRoomHybridStorage supports multiple xmppStreams,
29 | * this property may be used to differentiate between occupant objects.
30 | **/
31 | @property (readonly) XMPPJID * streamFullJid;
32 |
33 | /**
34 | * Sample comparison methods.
35 | **/
36 |
37 | - (NSComparisonResult)compareByNickname:(XMPPRoomOccupantHybridMemoryStorageObject *)another;
38 |
39 | - (NSComparisonResult)compareByCreatedAt:(XMPPRoomOccupantHybridMemoryStorageObject *)another;
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/MemoryStorage/XMPPRoomMessageMemoryStorageObject.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPRoomMessage.h"
3 |
4 |
5 | @interface XMPPRoomMessageMemoryStorageObject : NSObject
6 |
7 | - (id)initWithIncomingMessage:(XMPPMessage *)message;
8 | - (id)initWithOutgoingMessage:(XMPPMessage *)message jid:(XMPPJID *)myRoomJID;
9 |
10 | /**
11 | * The properties below are documented in the XMPPRoomMessage protocol.
12 | **/
13 |
14 | @property (nonatomic, readonly) XMPPMessage *message;
15 |
16 | @property (nonatomic, readonly) XMPPJID * roomJID;
17 |
18 | @property (nonatomic, readonly) XMPPJID * jid;
19 | @property (nonatomic, readonly) NSString * nickname;
20 |
21 | @property (nonatomic, readonly) NSDate * localTimestamp;
22 | @property (nonatomic, readonly) NSDate * remoteTimestamp;
23 |
24 | @property (nonatomic, readonly) BOOL isFromMe;
25 |
26 | /**
27 | * Compares two messages based on the localTimestamp.
28 | *
29 | * This method provides the ordering used by XMPPRoomMemoryStorage.
30 | * Subclasses may override this method to provide an alternative sorting mechanism.
31 | **/
32 | - (NSComparisonResult)compare:(XMPPRoomMessageMemoryStorageObject *)another;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/MemoryStorage/XMPPRoomOccupantMemoryStorageObject.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPRoom.h"
3 | #import "XMPPRoomOccupant.h"
4 |
5 |
6 | @interface XMPPRoomOccupantMemoryStorageObject : NSObject
7 |
8 | - (id)initWithPresence:(XMPPPresence *)presence;
9 | - (void)updateWithPresence:(XMPPPresence *)presence;
10 |
11 | /**
12 | * The properties below are documented in the XMPPRoomOccupant protocol.
13 | **/
14 |
15 | @property (readonly) XMPPPresence *presence;
16 |
17 | @property (readonly) XMPPJID * jid;
18 | @property (readonly) XMPPJID * roomJID;
19 | @property (readonly) NSString * nickname;
20 |
21 | @property (readonly) NSString * role;
22 | @property (readonly) NSString * affiliation;
23 | @property (readonly) XMPPJID * realJID;
24 |
25 | /**
26 | * Compares two occupants based on the nickname.
27 | *
28 | * This method provides the ordering used by XMPPRoomMemoryStorage.
29 | * Subclasses may override this method to provide an alternative sorting mechanism.
30 | **/
31 | - (NSComparisonResult)compare:(XMPPRoomOccupantMemoryStorageObject *)another;
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/XMPPMessage+XEP0045.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPMessage.h"
3 |
4 |
5 | @interface XMPPMessage(XEP0045)
6 |
7 | - (BOOL)isGroupChatMessage;
8 | - (BOOL)isGroupChatMessageWithBody;
9 | - (BOOL)isGroupChatMessageWithSubject;
10 |
11 | @end
12 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/XMPPMessage+XEP0045.m:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage+XEP0045.h"
2 | #import "NSXMLElement+XMPP.h"
3 |
4 |
5 | @implementation XMPPMessage(XEP0045)
6 |
7 | - (BOOL)isGroupChatMessage
8 | {
9 | return [[[self attributeForName:@"type"] stringValue] isEqualToString:@"groupchat"];
10 | }
11 |
12 | - (BOOL)isGroupChatMessageWithBody
13 | {
14 | if ([self isGroupChatMessage])
15 | {
16 | NSString *body = [[self elementForName:@"body"] stringValue];
17 |
18 | return ([body length] > 0);
19 | }
20 |
21 | return NO;
22 | }
23 |
24 | - (BOOL)isGroupChatMessageWithSubject
25 | {
26 | if ([self isGroupChatMessage])
27 | {
28 | NSString *subject = [[self elementForName:@"subject"] stringValue];
29 |
30 | return ([subject length] > 0);
31 | }
32 |
33 | return NO;
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/XMPPRoomMessage.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @class XMPPJID;
4 | @class XMPPMessage;
5 |
6 |
7 | @protocol XMPPRoomMessage
8 |
9 | /**
10 | * The raw message that was sent / received.
11 | **/
12 | - (XMPPMessage *)message;
13 |
14 | /**
15 | * The JID of the MUC room.
16 | **/
17 | - (XMPPJID *)roomJID;
18 |
19 | /**
20 | * Who sent the message.
21 | * A typical MUC room jid is of the form "room_name@conference.domain.tld/some_nickname".
22 | **/
23 | - (XMPPJID *)jid;
24 |
25 | /**
26 | * The nickname of the user who sent the message.
27 | * This is a convenience method for [jid resource].
28 | **/
29 | - (NSString *)nickname;
30 |
31 | /**
32 | * Convenience method to access the body of the message.
33 | **/
34 | - (NSString *)body;
35 |
36 | /**
37 | * When the message was sent / received (as recorded by us).
38 | *
39 | * If the message was originally sent by us, the localTimestamp is recorded automatically.
40 | * If the message was received, the server may have included a delayed delivery date timestamp.
41 | * This is the case when first joining a room, and downloading the discussion history.
42 | * In such a case, the localTimestamp will be a reflection of the serverTimestamp.
43 | **/
44 | - (NSDate *)localTimestamp;
45 |
46 | /**
47 | * When the message was sent / received (as recorded by the server).
48 | *
49 | * Only set when the server includes a delayedDelivery timestamp within the message.
50 | **/
51 | - (NSDate *)remoteTimestamp;
52 |
53 | /**
54 | * Whether or not the message was sent by us.
55 | **/
56 | - (BOOL)isFromMe;
57 |
58 | @end
59 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/XMPPRoomOccupant.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @class XMPPJID;
4 | @class XMPPPresence;
5 |
6 |
7 | @protocol XMPPRoomOccupant
8 |
9 | /**
10 | * Most recent presence message from occupant.
11 | **/
12 | - (XMPPPresence *)presence;
13 |
14 | /**
15 | * The MUC room the occupant is associated with.
16 | **/
17 | - (XMPPJID *)roomJID;
18 |
19 | /**
20 | * The JID of the occupant as reported by the room.
21 | * A typical MUC room will use JIDs of the form: "room_name@conference.domain.tl/some_nickname".
22 | **/
23 | - (XMPPJID *)jid;
24 |
25 | /**
26 | * The nickname of the user.
27 | * In other words, the resource portion of the occupants JID.
28 | **/
29 | - (NSString *)nickname;
30 |
31 | /**
32 | * The 'role' and 'affiliation' of the occupant within the MUC room.
33 | *
34 | * From XEP-0045, Section 5 - Roles and Affiliations:
35 | *
36 | * There are two dimensions along which we can measure a user's connection with or position in a room.
37 | * One is the user's long-lived affiliation with a room -- e.g., a user's status as an owner or an outcast.
38 | * The other is a user's role while an occupant of a room -- e.g., an occupant's position as a moderator with the
39 | * ability to kick visitors and participants. These two dimensions are distinct from each other, since an affiliation
40 | * lasts across visits, while a role lasts only for the duration of a visit. In addition, there is no one-to-one
41 | * correspondence between roles and affiliations; for example, someone who is not affiliated with a room may be
42 | * a (temporary) moderator, and a member may be a participant or a visitor in a moderated room.
43 | *
44 | * For more information, please see XEP-0045.
45 | **/
46 | - (NSString *)role;
47 | - (NSString *)affiliation;
48 |
49 | /**
50 | * If the MUC room is non-anonymous, the real JID of the user will be broadcast.
51 | *
52 | * An anonymous room uses JID's of the form: "room_name@conference.domain.tld/some_nickname".
53 | * A non-anonymous room also includes the occupants real full JID in the presence broadcast.
54 | **/
55 | - (XMPPJID *)realJID;
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0045/XMPPRoomPrivate.h:
--------------------------------------------------------------------------------
1 | #import "XMPPRoom.h"
2 |
3 |
4 | @interface XMPPRoom (PrivateInternalAPI)
5 |
6 | /**
7 | * XMPPRoomStorage classes may optionally use the same delegate(s) as their parent XMPPRoom.
8 | * This method allows such storage classes to access the delegate(s).
9 | *
10 | * Note: If the storage class operates on a different queue than its parent,
11 | * it MUST dispatch all calls to the multicastDelegate onto its parent's queue.
12 | * The parent's dispatch queue is passed in the configureWithParent:queue: method,
13 | * or may be obtained via the moduleQueue method below.
14 | **/
15 | - (GCDMulticastDelegate *)multicastDelegate;
16 |
17 | - (dispatch_queue_t)moduleQueue;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/CoreDataStorage/XMPPvCard.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | XMPPvCard.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/CoreDataStorage/XMPPvCard.xcdatamodeld/XMPPvCard.xcdatamodel/elements:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/XMPP/Extensions/XEP-0054/CoreDataStorage/XMPPvCard.xcdatamodeld/XMPPvCard.xcdatamodel/elements
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/CoreDataStorage/XMPPvCard.xcdatamodeld/XMPPvCard.xcdatamodel/layout:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/XMPP/Extensions/XEP-0054/CoreDataStorage/XMPPvCard.xcdatamodeld/XMPPvCard.xcdatamodel/layout
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/CoreDataStorage/XMPPvCardAvatarCoreDataStorageObject.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardAvatarCoreDataStorageObject.h
3 | // XEP-0054 vCard-temp
4 | //
5 | // Originally created by Eric Chamberlain on 3/18/11.
6 | //
7 | // This class is so that we don't load the photoData each time we need to touch the XMPPvCardCoreDataStorageObject.
8 |
9 | #import
10 | #import
11 |
12 | @class XMPPvCardCoreDataStorageObject;
13 |
14 |
15 | @interface XMPPvCardAvatarCoreDataStorageObject : NSManagedObject
16 |
17 | @property (nonatomic, strong) NSData * photoData;
18 | @property (nonatomic, strong) XMPPvCardCoreDataStorageObject * vCard;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/CoreDataStorage/XMPPvCardAvatarCoreDataStorageObject.m:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardAvatarCoreDataStorageObject.m
3 | // XEP-0054 vCard-temp
4 | //
5 | // Originally created by Eric Chamberlain on 3/18/11.
6 | //
7 |
8 | #import "XMPPvCardAvatarCoreDataStorageObject.h"
9 | #import "XMPPvCardCoreDataStorageObject.h"
10 |
11 |
12 | @implementation XMPPvCardAvatarCoreDataStorageObject
13 |
14 | @dynamic photoData;
15 | @dynamic vCard;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/CoreDataStorage/XMPPvCardCoreDataStorage.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardCoreDataStorage.h
3 | // XEP-0054 vCard-temp
4 | //
5 | // Originally created by Eric Chamberlain on 3/18/11.
6 | //
7 |
8 | #import
9 | #import
10 |
11 | #import "XMPPCoreDataStorage.h"
12 | #import "XMPPvCardTempModule.h"
13 | #import "XMPPvCardAvatarModule.h"
14 |
15 | /**
16 | * This class is an example implementation of XMPPCapabilitiesStorage using core data.
17 | * You are free to substitute your own storage class.
18 | **/
19 |
20 | @interface XMPPvCardCoreDataStorage : XMPPCoreDataStorage <
21 | XMPPvCardAvatarStorage,
22 | XMPPvCardTempModuleStorage
23 | > {
24 | // Inherits protected variables from XMPPCoreDataStorage
25 | }
26 |
27 | /**
28 | * XEP-0054 provides a mechanism for transmitting vCards via XMPP.
29 | * Because the JID doesn't change very often and can be large with image data,
30 | * it is safe to persistently store the JID and wait for a user to explicity ask for an update,
31 | * or use XEP-0153 to monitor for JID changes.
32 | *
33 | * For this reason, it is recommended you use this sharedInstance across all your xmppStreams.
34 | * This way all streams can shared a knowledgebase concerning known JIDs and Avatar photos.
35 | *
36 | * All other aspects of vCard handling (such as lookup failures, etc) are kept separate between streams.
37 | **/
38 | + (instancetype)sharedInstance;
39 |
40 | //
41 | // This class inherits from XMPPCoreDataStorage.
42 | //
43 | // Please see the XMPPCoreDataStorage header file for more information.
44 | //
45 |
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/CoreDataStorage/XMPPvCardCoreDataStorageObject.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardCoreDataStorageObject.h
3 | // XEP-0054 vCard-temp
4 | //
5 | // Originally created by Eric Chamberlain on 3/18/11.
6 | //
7 |
8 | #import
9 | #import
10 |
11 |
12 | @class XMPPJID;
13 | @class XMPPvCardTemp;
14 | @class XMPPvCardTempCoreDataStorageObject;
15 | @class XMPPvCardAvatarCoreDataStorageObject;
16 |
17 |
18 | @interface XMPPvCardCoreDataStorageObject : NSManagedObject
19 |
20 |
21 | /*
22 | * User's JID, indexed for lookups
23 | */
24 | @property (nonatomic, strong) NSString * jidStr;
25 |
26 | /*
27 | * User's photoHash used by XEP-0153
28 | */
29 | @property (nonatomic, strong, readonly) NSString * photoHash;
30 |
31 | /*
32 | * The last time the record was modified, also used to determine if we need to fetch again
33 | */
34 | @property (nonatomic, strong) NSDate * lastUpdated;
35 |
36 |
37 | /*
38 | * Flag indicating whether a get request is already pending, used in conjunction with lastUpdated
39 | */
40 | @property (nonatomic, strong) NSNumber * waitingForFetch;
41 |
42 |
43 | /*
44 | * Relationship to the vCardTemp record.
45 | * We use a relationship, so the vCardTemp stays faulted until we really need it.
46 | */
47 | @property (nonatomic, strong) XMPPvCardTempCoreDataStorageObject * vCardTempRel;
48 |
49 |
50 | /*
51 | * Relationship to the vCardAvatar record.
52 | * We use a relationship, so the vCardAvatar stays faulted until we really need it.
53 | */
54 | @property (nonatomic, strong) XMPPvCardAvatarCoreDataStorageObject * vCardAvatarRel;
55 |
56 |
57 | /*
58 | * Accessor to retrieve photoData, so we can hide the underlying relationship implementation.
59 | */
60 | @property (nonatomic, strong) NSData *photoData;
61 |
62 |
63 | /*
64 | * Accessor to retrieve vCardTemp, so we can hide the underlying relationship implementation.
65 | */
66 | @property (nonatomic, strong) XMPPvCardTemp *vCardTemp;
67 |
68 |
69 | + (XMPPvCardCoreDataStorageObject *)fetchOrInsertvCardForJID:(XMPPJID *)jid
70 | inManagedObjectContext:(NSManagedObjectContext *)moc;
71 |
72 |
73 | @end
74 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/CoreDataStorage/XMPPvCardTempCoreDataStorageObject.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardTempCoreDataStorageObject.h
3 | // XEP-0054 vCard-temp
4 | //
5 | // Oringally created by Eric Chamberlain on 3/18/11.
6 | //
7 | // This class is so that we don't load the vCardTemp each time we need to touch the XMPPvCardCoreDataStorageObject.
8 | // The vCardTemp abstraction also makes it easier to eventually add support for vCard4 over XMPP (XEP-0292).
9 |
10 | #import
11 | #import
12 |
13 | #import "XMPPvcardTemp.h"
14 |
15 | @class XMPPvCardCoreDataStorageObject;
16 |
17 |
18 | @interface XMPPvCardTempCoreDataStorageObject : NSManagedObject
19 |
20 | @property (nonatomic, strong) XMPPvCardTemp * vCardTemp;
21 | @property (nonatomic, strong) XMPPvCardCoreDataStorageObject * vCard;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/CoreDataStorage/XMPPvCardTempCoreDataStorageObject.m:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardTempCoreDataStorageObject.m
3 | // XEP-0054 vCard-temp
4 | //
5 | // Originally created by Eric Chamberlain on 3/18/11.
6 | //
7 |
8 | #import "XMPPvCardTempCoreDataStorageObject.h"
9 | #import "XMPPvCardCoreDataStorageObject.h"
10 |
11 |
12 | @implementation XMPPvCardTempCoreDataStorageObject
13 |
14 | @dynamic vCardTemp;
15 | @dynamic vCard;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/XMPPvCardTempAdr.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardTempAdr.h
3 | // XEP-0054 vCard-temp
4 | //
5 | // Created by Eric Chamberlain on 3/9/11.
6 | // Copyright 2011 RF.com. All rights reserved.
7 | // Copyright 2010 Martin Morrison. All rights reserved.
8 | //
9 |
10 |
11 | #import
12 |
13 | #import "XMPPvCardTempAdrTypes.h"
14 |
15 |
16 | @interface XMPPvCardTempAdr : XMPPvCardTempAdrTypes
17 |
18 | + (XMPPvCardTempAdr *)vCardAdrFromElement:(NSXMLElement *)elem;
19 |
20 | @property (nonatomic, weak) NSString *pobox;
21 | @property (nonatomic, weak) NSString *extendedAddress;
22 | @property (nonatomic, weak) NSString *street;
23 | @property (nonatomic, weak) NSString *locality;
24 | @property (nonatomic, weak) NSString *region;
25 | @property (nonatomic, weak) NSString *postalCode;
26 | @property (nonatomic, weak) NSString *country;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/XMPPvCardTempAdrTypes.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardTempAdrTypes.h
3 | // XEP-0054 vCard-temp
4 | //
5 | // Created by Eric Chamberlain on 3/9/11.
6 | // Copyright 2011 RF.com. All rights reserved.
7 | // Copyright 2010 Martin Morrison. All rights reserved.
8 | //
9 |
10 |
11 | #import
12 |
13 | #import "XMPPvCardTempBase.h"
14 |
15 |
16 | @interface XMPPvCardTempAdrTypes : XMPPvCardTempBase
17 |
18 |
19 | @property (nonatomic, assign, setter=setHome:) BOOL isHome;
20 | @property (nonatomic, assign, setter=setWork:) BOOL isWork;
21 | @property (nonatomic, assign, setter=setParcel:) BOOL isParcel;
22 | @property (nonatomic, assign, setter=setPostal:) BOOL isPostal;
23 | @property (nonatomic, assign, setter=setDomestic:) BOOL isDomestic;
24 | @property (nonatomic, assign, setter=setInternational:) BOOL isInternational;
25 | @property (nonatomic, assign, setter=setPreferred:) BOOL isPreferred;
26 |
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/XMPPvCardTempAdrTypes.m:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardTempAdrTypes.m
3 | // XEP-0054 vCard-temp
4 | //
5 | // Created by Eric Chamberlain on 3/9/11.
6 | // Copyright 2011 RF.com. All rights reserved.
7 | // Copyright 2010 Martin Morrison. All rights reserved.
8 | //
9 |
10 |
11 | #import "XMPPvCardTempAdrTypes.h"
12 |
13 | #if ! __has_feature(objc_arc)
14 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
15 | #endif
16 |
17 |
18 | @implementation XMPPvCardTempAdrTypes
19 |
20 |
21 | #pragma mark -
22 | #pragma mark Getter/setter methods
23 |
24 |
25 | - (BOOL)isHome {
26 | return [self elementForName:@"HOME"] != nil;
27 | }
28 |
29 |
30 | - (void)setHome:(BOOL)home {
31 | XMPP_VCARD_SET_EMPTY_CHILD(home && ![self isHome], @"HOME");
32 | }
33 |
34 |
35 | - (BOOL)isWork {
36 | return [self elementForName:@"WORK"] != nil;
37 | }
38 |
39 |
40 | - (void)setWork:(BOOL)work {
41 | XMPP_VCARD_SET_EMPTY_CHILD(work && ![self isWork], @"WORK");
42 | }
43 |
44 |
45 | - (BOOL)isParcel {
46 | return [self elementForName:@"PARCEL"] != nil;
47 | }
48 |
49 |
50 | - (void)setParcel:(BOOL)parcel {
51 | XMPP_VCARD_SET_EMPTY_CHILD(parcel && ![self isParcel], @"PARCEL");
52 | }
53 |
54 |
55 | - (BOOL)isPostal {
56 | return [self elementForName:@"POSTAL"] != nil;
57 | }
58 |
59 |
60 | - (void)setPostal:(BOOL)postal {
61 | XMPP_VCARD_SET_EMPTY_CHILD(postal && ![self isPostal], @"POSTAL");
62 | }
63 |
64 |
65 | - (BOOL)isDomestic {
66 | return [self elementForName:@"DOM"] != nil;
67 | }
68 |
69 |
70 | - (void)setDomestic:(BOOL)dom {
71 | XMPP_VCARD_SET_EMPTY_CHILD(dom && ![self isDomestic], @"DOM");
72 | // INTL and DOM are mutually exclusive
73 | if (dom) {
74 | [self setInternational:NO];
75 | }
76 | }
77 |
78 |
79 | - (BOOL)isInternational {
80 | return [self elementForName:@"INTL"] != nil;
81 | }
82 |
83 |
84 | - (void)setInternational:(BOOL)intl {
85 | XMPP_VCARD_SET_EMPTY_CHILD(intl && ![self isInternational], @"INTL");
86 | // INTL and DOM are mutually exclusive
87 | if (intl) {
88 | [self setDomestic:NO];
89 | }
90 | }
91 |
92 |
93 | - (BOOL)isPreferred {
94 | return [self elementForName:@"PREF"] != nil;
95 | }
96 |
97 |
98 | - (void)setPreferred:(BOOL)pref {
99 | XMPP_VCARD_SET_EMPTY_CHILD(pref && ![self isPreferred], @"PREF");
100 | }
101 |
102 |
103 | @end
104 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/XMPPvCardTempEmail.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardTempEmail.h
3 | // XEP-0054 vCard-temp
4 | //
5 | // Created by Eric Chamberlain on 3/9/11.
6 | // Copyright 2011 RF.com. All rights reserved.
7 | // Copyright 2010 Martin Morrison. All rights reserved.
8 | //
9 |
10 |
11 | #import
12 |
13 | #import "XMPPvCardTempBase.h"
14 |
15 |
16 | @interface XMPPvCardTempEmail : XMPPvCardTempBase
17 |
18 | + (XMPPvCardTempEmail *)vCardEmailFromElement:(NSXMLElement *)elem;
19 |
20 | @property (nonatomic, assign, setter=setHome:) BOOL isHome;
21 | @property (nonatomic, assign, setter=setWork:) BOOL isWork;
22 | @property (nonatomic, assign, setter=setInternet:) BOOL isInternet;
23 | @property (nonatomic, assign, setter=setX400:) BOOL isX400;
24 | @property (nonatomic, assign, setter=setPreferred:) BOOL isPreferred;
25 |
26 | @property (nonatomic, weak) NSString *userid;
27 |
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/XMPPvCardTempLabel.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardTempLabel.h
3 | // XEP-0054 vCard-temp
4 | //
5 | // Created by Eric Chamberlain on 3/9/11.
6 | // Copyright 2011 RF.com. All rights reserved.
7 | // Copyright 2010 Martin Morrison. All rights reserved.
8 | //
9 |
10 |
11 | #import
12 |
13 | #import "XMPPvCardTempAdrTypes.h"
14 |
15 |
16 | @interface XMPPvCardTempLabel : XMPPvCardTempAdrTypes
17 |
18 |
19 | @property (nonatomic, weak) NSArray *lines;
20 |
21 |
22 | + (XMPPvCardTempLabel *)vCardLabelFromElement:(NSXMLElement *)elem;
23 |
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/XMPPvCardTempLabel.m:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardTempLabel.m
3 | // XEP-0054 vCard-temp
4 | //
5 | // Created by Eric Chamberlain on 3/9/11.
6 | // Copyright 2011 RF.com. All rights reserved.
7 | // Copyright 2010 Martin Morrison. All rights reserved.
8 | //
9 |
10 |
11 | #import "XMPPvCardTempLabel.h"
12 | #import "XMPPLogging.h"
13 |
14 | #import
15 |
16 | #if ! __has_feature(objc_arc)
17 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
18 | #endif
19 |
20 | #if DEBUG
21 | static const int xmppLogLevel = XMPP_LOG_LEVEL_ERROR;
22 | #endif
23 |
24 |
25 | @implementation XMPPvCardTempLabel
26 |
27 | #if DEBUG
28 |
29 | + (void)initialize {
30 | // We use the object_setClass method below to dynamically change the class from a standard NSXMLElement.
31 | // The size of the two classes is expected to be the same.
32 | //
33 | // If a developer adds instance methods to this class, bad things happen at runtime that are very hard to debug.
34 | // This check is here to aid future developers who may make this mistake.
35 | //
36 | // For Fearless And Experienced Objective-C Developers:
37 | // It may be possible to support adding instance variables to this class if you seriously need it.
38 | // To do so, try realloc'ing self after altering the class, and then initialize your variables.
39 |
40 | size_t superSize = class_getInstanceSize([NSXMLElement class]);
41 | size_t ourSize = class_getInstanceSize([XMPPvCardTempLabel class]);
42 |
43 | if (superSize != ourSize)
44 | {
45 | XMPPLogError(@"Adding instance variables to XMPPvCardTempLabel is not currently supported!");
46 |
47 | [DDLog flushLog];
48 | exit(15);
49 | }
50 | }
51 |
52 | #endif
53 |
54 | + (XMPPvCardTempLabel *)vCardLabelFromElement:(NSXMLElement *)elem {
55 | object_setClass(elem, [XMPPvCardTempLabel class]);
56 |
57 | return (XMPPvCardTempLabel *)elem;
58 | }
59 |
60 |
61 | #pragma mark -
62 | #pragma mark Getter/setter methods
63 |
64 |
65 | - (NSArray *)lines {
66 | NSArray *elems = [self elementsForName:@"LINE"];
67 | NSMutableArray *lines = [[NSMutableArray alloc] initWithCapacity:[elems count]];
68 |
69 | for (NSXMLElement *elem in elems) {
70 | [lines addObject:[elem stringValue]];
71 | }
72 |
73 | NSArray *result = [NSArray arrayWithArray:lines];
74 | return result;
75 | }
76 |
77 |
78 | - (void)setLines:(NSArray *)lines {
79 | NSArray *elems = [self elementsForName:@"LINE"];
80 |
81 | for (NSXMLElement *elem in elems) {
82 | [self removeChildAtIndex:[[self children] indexOfObject:elem]];
83 | }
84 |
85 | for (NSString *line in lines) {
86 | NSXMLElement *elem = [NSXMLElement elementWithName:@"LINE"];
87 | [elem setStringValue:line];
88 | [self addChild:elem];
89 | }
90 | }
91 |
92 |
93 | @end
94 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0054/XMPPvCardTempTel.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPvCardTempTel.h
3 | // XEP-0054 vCard-temp
4 | //
5 | // Created by Eric Chamberlain on 3/9/11.
6 | // Copyright 2011 RF.com. All rights reserved.
7 | // Copyright 2010 Martin Morrison. All rights reserved.
8 | //
9 |
10 |
11 | #import
12 |
13 | #import "XMPPvCardTempBase.h"
14 |
15 |
16 | @interface XMPPvCardTempTel : XMPPvCardTempBase
17 |
18 |
19 | + (XMPPvCardTempTel *)vCardTelFromElement:(NSXMLElement *)elem;
20 |
21 | @property (nonatomic, assign, setter=setHome:) BOOL isHome;
22 | @property (nonatomic, assign, setter=setWork:) BOOL isWork;
23 | @property (nonatomic, assign, setter=setVoice:) BOOL isVoice;
24 | @property (nonatomic, assign, setter=setFax:) BOOL isFax;
25 | @property (nonatomic, assign, setter=setPager:) BOOL isPager;
26 | @property (nonatomic, assign, setter=setMessaging:) BOOL hasMessaging;
27 | @property (nonatomic, assign, setter=setCell:) BOOL isCell;
28 | @property (nonatomic, assign, setter=setVideo:) BOOL isVideo;
29 | @property (nonatomic, assign, setter=setBBS:) BOOL isBBS;
30 | @property (nonatomic, assign, setter=setModem:) BOOL isModem;
31 | @property (nonatomic, assign, setter=setISDN:) BOOL isISDN;
32 | @property (nonatomic, assign, setter=setPCS:) BOOL isPCS;
33 | @property (nonatomic, assign, setter=setPreferred:) BOOL isPreferred;
34 |
35 | @property (nonatomic, weak) NSString *number;
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0059/NSXMLElement+XEP_0059.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #if TARGET_OS_IPHONE
4 | #import "DDXML.h"
5 | #endif
6 |
7 | @class XMPPResultSet;
8 |
9 |
10 | @interface NSXMLElement (XEP_0059)
11 |
12 | - (BOOL)isResultSet;
13 | - (BOOL)hasResultSet;
14 | - (XMPPResultSet *)resultSet;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0059/NSXMLElement+XEP_0059.m:
--------------------------------------------------------------------------------
1 | #import "NSXMLElement+XEP_0059.h"
2 | #import "NSXMLElement+XMPP.h"
3 | #import "XMPPResultSet.h"
4 |
5 | #if ! __has_feature(objc_arc)
6 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
7 | #endif
8 |
9 |
10 | #define XMLNS_XMPP_RESULT_SET @"http://jabber.org/protocol/rsm"
11 | #define NAME_XMPP_RESULT_SET @"set"
12 |
13 | @implementation NSXMLElement (XEP_0059)
14 |
15 |
16 | - (BOOL)isResultSet
17 | {
18 | if([[self name] isEqualToString:NAME_XMPP_RESULT_SET] && [[self xmlns] isEqualToString:XMLNS_XMPP_RESULT_SET])
19 | {
20 | return YES;
21 | }
22 | else
23 | {
24 | return NO;
25 | }
26 | }
27 |
28 | - (BOOL)hasResultSet
29 | {
30 | if([self resultSet])
31 | {
32 | return YES;
33 | }
34 | else
35 | {
36 | return NO;
37 | }
38 | }
39 |
40 | - (XMPPResultSet *)resultSet
41 | {
42 | NSXMLElement *resultSetElement = [self elementForName:NAME_XMPP_RESULT_SET xmlns:XMLNS_XMPP_RESULT_SET];
43 | XMPPResultSet *resultSet = [XMPPResultSet resultSetFromElement:resultSetElement];
44 | return resultSet;
45 | }
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0060/XMPPIQ+XEP_0060.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPIQ.h"
3 |
4 | #define XMLNS_PUBSUB @"http://jabber.org/protocol/pubsub"
5 | #define XMLNS_PUBSUB_OWNER @"http://jabber.org/protocol/pubsub#owner"
6 | #define XMLNS_PUBSUB_EVENT @"http://jabber.org/protocol/pubsub#event"
7 | #define XMLNS_PUBSUB_NODE_CONFIG @"http://jabber.org/protocol/pubsub#node_config"
8 | #define XMLNS_PUBSUB_PUBLISH_OPTIONS @"http://jabber.org/protocol/pubsub#publish-options"
9 | #define XMLNS_PUBSUB_SUBSCRIBE_OPTIONS @"http://jabber.org/protocol/pubsub#subscribe_options"
10 |
11 | @interface XMPPIQ (XEP_0060)
12 |
13 | /**
14 | * Extracts the 'subid' from a PubSub subscription response.
15 | *
16 | * For example, if we sent a PubSub subscription request for node "princely_musings",
17 | * and the server returned this response:
18 | *
19 | *
20 | *
21 | *
26 | *
27 | *
28 | *
29 | * Then this method would return "ba49252aaa4f5d320c24d3766f0bdcade78c78d3".
30 | *
31 | * It is common to store the subid as it often a required attribute when unsubscribing.
32 | **/
33 | - (NSString *)pubsubid;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0060/XMPPIQ+XEP_0060.m:
--------------------------------------------------------------------------------
1 | #import "XMPPIQ+XEP_0060.h"
2 | #import "NSXMLElement+XMPP.h"
3 |
4 |
5 | @implementation XMPPIQ (XEP_0060)
6 |
7 | - (NSString *)pubsubid
8 | {
9 | //
10 | //
11 | //
16 | //
17 | //
18 |
19 | NSXMLElement *pubsub = [self elementForName:@"pubsub" xmlns:XMLNS_PUBSUB];
20 | NSXMLElement *subscription = [pubsub elementForName:@"subscription"];
21 |
22 | return [subscription attributeStringValueForName:@"subid"];
23 | }
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0065/TURNSocket.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @class XMPPIQ;
4 | @class XMPPJID;
5 | @class XMPPStream;
6 | @class GCDAsyncSocket;
7 |
8 | /**
9 | * TURNSocket is an implementation of XEP-0065: SOCKS5 Bytestreams.
10 | *
11 | * It is used for establishing an out-of-band bytestream between any two XMPP users,
12 | * mainly for the purpose of file transfer.
13 | **/
14 | @interface TURNSocket : NSObject
15 | {
16 | int state;
17 | BOOL isClient;
18 |
19 | dispatch_queue_t turnQueue;
20 | void *turnQueueTag;
21 |
22 | XMPPStream *xmppStream;
23 | XMPPJID *jid;
24 | NSString *uuid;
25 |
26 | id delegate;
27 | dispatch_queue_t delegateQueue;
28 |
29 | dispatch_source_t turnTimer;
30 |
31 | NSString *discoUUID;
32 | dispatch_source_t discoTimer;
33 |
34 | NSArray *proxyCandidates;
35 | NSUInteger proxyCandidateIndex;
36 |
37 | NSMutableArray *candidateJIDs;
38 | NSUInteger candidateJIDIndex;
39 |
40 | NSMutableArray *streamhosts;
41 | NSUInteger streamhostIndex;
42 |
43 | XMPPJID *proxyJID;
44 | NSString *proxyHost;
45 | UInt16 proxyPort;
46 |
47 | GCDAsyncSocket *asyncSocket;
48 |
49 | NSDate *startTime, *finishTime;
50 | }
51 |
52 | + (BOOL)isNewStartTURNRequest:(XMPPIQ *)iq;
53 |
54 | + (NSArray *)proxyCandidates;
55 | + (void)setProxyCandidates:(NSArray *)candidates;
56 |
57 | - (id)initWithStream:(XMPPStream *)xmppStream toJID:(XMPPJID *)jid;
58 | - (id)initWithStream:(XMPPStream *)xmppStream incomingTURNRequest:(XMPPIQ *)iq;
59 |
60 | - (void)startWithDelegate:(id)aDelegate delegateQueue:(dispatch_queue_t)aDelegateQueue;
61 |
62 | - (BOOL)isClient;
63 |
64 | - (void)abort;
65 |
66 | @end
67 |
68 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
69 | #pragma mark -
70 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
71 |
72 | @protocol TURNSocketDelegate
73 | @optional
74 |
75 | - (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket;
76 |
77 | - (void)turnSocketDidFail:(TURNSocket *)sender;
78 |
79 | @end
80 |
81 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0066/XMPPIQ+XEP_0066.h:
--------------------------------------------------------------------------------
1 | #import "XMPPIQ.h"
2 |
3 | @interface XMPPIQ (XEP_0066)
4 |
5 | + (XMPPIQ *)outOfBandDataRequestTo:(XMPPJID *)jid
6 | elementID:(NSString *)eid
7 | URL:(NSURL *)URL
8 | desc:(NSString *)dec;
9 |
10 | + (XMPPIQ *)outOfBandDataRequestTo:(XMPPJID *)jid
11 | elementID:(NSString *)eid
12 | URI:(NSString *)URI
13 | desc:(NSString *)dec;
14 |
15 |
16 | - (id)initOutOfBandDataRequestTo:(XMPPJID *)jid
17 | elementID:(NSString *)eid
18 | URL:(NSURL *)URL
19 | desc:(NSString *)dec;
20 |
21 | - (id)initOutOfBandDataRequestTo:(XMPPJID *)jid
22 | elementID:(NSString *)eid
23 | URI:(NSString *)URI
24 | desc:(NSString *)dec;
25 |
26 | - (void)addOutOfBandURL:(NSURL *)URL desc:(NSString *)desc;
27 | - (void)addOutOfBandURI:(NSString *)URI desc:(NSString *)desc;
28 |
29 | - (XMPPIQ *)generateOutOfBandDataSuccessResponse;
30 |
31 | - (XMPPIQ *)generateOutOfBandDataFailureResponse;
32 |
33 | - (XMPPIQ *)generateOutOfBandDataRejectResponse;
34 |
35 | - (BOOL)isOutOfBandDataRequest;
36 | - (BOOL)isOutOfBandDataFailureResponse;
37 | - (BOOL)isOutOfBandDataRejectResponse;
38 |
39 | - (BOOL)hasOutOfBandData;
40 |
41 | - (NSURL *)outOfBandURL;
42 | - (NSString *)outOfBandURI;
43 | - (NSString *)outOfBandDesc;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0066/XMPPMessage+XEP_0066.h:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage.h"
2 |
3 | @interface XMPPMessage (XEP_0066)
4 |
5 | - (void)addOutOfBandURL:(NSURL *)URL desc:(NSString *)desc;
6 | - (void)addOutOfBandURI:(NSString *)URI desc:(NSString *)desc;
7 |
8 | - (BOOL)hasOutOfBandData;
9 |
10 | - (NSURL *)outOfBandURL;
11 | - (NSString *)outOfBandURI;
12 | - (NSString *)outOfBandDesc;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0066/XMPPMessage+XEP_0066.m:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage+XEP_0066.h"
2 | #import "NSXMLElement+XMPP.h"
3 |
4 | #if ! __has_feature(objc_arc)
5 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
6 | #endif
7 |
8 | #define NAME_OUT_OF_BAND @"x"
9 | #define XMLNS_OUT_OF_BAND @"jabber:iq:oob"
10 |
11 | @implementation XMPPMessage (XEP_0066)
12 |
13 | - (void)addOutOfBandURL:(NSURL *)URL desc:(NSString *)desc
14 | {
15 | NSXMLElement *outOfBand = [NSXMLElement elementWithName:NAME_OUT_OF_BAND xmlns:XMLNS_OUT_OF_BAND];
16 |
17 | if([[URL path] length])
18 | {
19 | NSXMLElement *URLElement = [NSXMLElement elementWithName:@"url" stringValue:[URL path]];
20 | [outOfBand addChild:URLElement];
21 | }
22 |
23 | if([desc length])
24 | {
25 | NSXMLElement *descElement = [NSXMLElement elementWithName:@"desc" stringValue:desc];
26 | [outOfBand addChild:descElement];
27 | }
28 |
29 | [self addChild:outOfBand];
30 | }
31 |
32 | - (void)addOutOfBandURI:(NSString *)URI desc:(NSString *)desc
33 | {
34 | NSXMLElement *outOfBand = [NSXMLElement elementWithName:NAME_OUT_OF_BAND xmlns:XMLNS_OUT_OF_BAND];
35 |
36 | if([URI length])
37 | {
38 | NSXMLElement *URLElement = [NSXMLElement elementWithName:@"url" stringValue:URI];
39 | [outOfBand addChild:URLElement];
40 | }
41 |
42 | if([desc length])
43 | {
44 | NSXMLElement *descElement = [NSXMLElement elementWithName:@"desc" stringValue:desc];
45 | [outOfBand addChild:descElement];
46 | }
47 |
48 | [self addChild:outOfBand];
49 | }
50 |
51 | - (BOOL)hasOutOfBandData
52 | {
53 | return ([self elementForName:NAME_OUT_OF_BAND xmlns:XMLNS_OUT_OF_BAND] ? YES : NO);
54 | }
55 |
56 | - (NSURL *)outOfBandURL
57 | {
58 | NSURL *URL = nil;
59 |
60 | NSXMLElement *outOfBand = [self elementForName:NAME_OUT_OF_BAND xmlns:XMLNS_OUT_OF_BAND];
61 |
62 | NSXMLElement *URLElement = [outOfBand elementForName:@"url"];
63 |
64 | NSString *URLString = [URLElement stringValue];
65 |
66 | if([URLString length])
67 | {
68 | URL = [NSURL URLWithString:URLString];
69 | }
70 |
71 | return URL;
72 |
73 | }
74 |
75 | - (NSString *)outOfBandURI
76 | {
77 | NSXMLElement *outOfBand = [self elementForName:NAME_OUT_OF_BAND xmlns:XMLNS_OUT_OF_BAND];
78 |
79 | NSXMLElement *URLElement = [outOfBand elementForName:@"url"];
80 |
81 | NSString *URI= [URLElement stringValue];
82 |
83 | return URI;
84 | }
85 |
86 | - (NSString *)outOfBandDesc
87 | {
88 | NSXMLElement *outOfBand = [self elementForName:NAME_OUT_OF_BAND xmlns:XMLNS_OUT_OF_BAND];
89 |
90 | NSXMLElement *descElement = [outOfBand elementForName:@"desc"];
91 |
92 | NSString *desc = [descElement stringValue];
93 |
94 | return desc;
95 | }
96 |
97 | @end
98 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0082/NSDate+XMPPDateTimeProfiles.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSDate+XMPPDateTimeProfiles.h
3 | //
4 | // NSDate category to implement XEP-0082.
5 | //
6 | // Created by Eric Chamberlain on 3/9/11.
7 | // Copyright 2011 RF.com. All rights reserved.
8 | // Copyright 2010 Martin Morrison. All rights reserved.
9 | //
10 |
11 | #import
12 |
13 | @interface NSDate(XMPPDateTimeProfiles)
14 |
15 |
16 | + (NSDate *)dateWithXmppDateString:(NSString *)str;
17 | + (NSDate *)dateWithXmppTimeString:(NSString *)str;
18 | + (NSDate *)dateWithXmppDateTimeString:(NSString *)str;
19 |
20 |
21 | - (NSString *)xmppDateString;
22 | - (NSString *)xmppTimeString;
23 | - (NSString *)xmppDateTimeString;
24 |
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0082/NSDate+XMPPDateTimeProfiles.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSDate+XMPPDateTimeProfiles.m
3 | //
4 | // NSDate category to implement XEP-0082.
5 | //
6 | // Created by Eric Chamberlain on 3/9/11.
7 | // Copyright 2011 RF.com. All rights reserved.
8 | // Copyright 2010 Martin Morrison. All rights reserved.
9 | //
10 |
11 | #import "NSDate+XMPPDateTimeProfiles.h"
12 | #import "XMPPDateTimeProfiles.h"
13 |
14 | #if ! __has_feature(objc_arc)
15 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
16 | #endif
17 |
18 | @interface NSDate(XMPPDateTimeProfilesPrivate)
19 | - (NSString *)xmppStringWithDateFormat:(NSString *)dateFormat;
20 | @end
21 |
22 | #pragma mark -
23 |
24 | @implementation NSDate(XMPPDateTimeProfiles)
25 |
26 |
27 | #pragma mark Convert from XMPP string to NSDate
28 |
29 |
30 | + (NSDate *)dateWithXmppDateString:(NSString *)str {
31 | return [XMPPDateTimeProfiles parseDate:str];
32 | }
33 |
34 |
35 | + (NSDate *)dateWithXmppTimeString:(NSString *)str {
36 | return [XMPPDateTimeProfiles parseTime:str];
37 | }
38 |
39 |
40 | + (NSDate *)dateWithXmppDateTimeString:(NSString *)str {
41 | return [XMPPDateTimeProfiles parseDateTime:str];
42 | }
43 |
44 |
45 | #pragma mark Convert from NSDate to XMPP string
46 |
47 |
48 | - (NSString *)xmppDateString {
49 | return [self xmppStringWithDateFormat:@"yyyy-MM-dd"];
50 | }
51 |
52 |
53 | - (NSString *)xmppTimeString {
54 | return [self xmppStringWithDateFormat:@"HH:mm:ss'Z'"];
55 | }
56 |
57 |
58 | - (NSString *)xmppDateTimeString {
59 | return [self xmppStringWithDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
60 | }
61 |
62 |
63 | #pragma mark XMPPDateTimeProfilesPrivate methods
64 |
65 |
66 | - (NSString *)xmppStringWithDateFormat:(NSString *)dateFormat
67 | {
68 | NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
69 | [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
70 | [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
71 | [dateFormatter setDateFormat:dateFormat];
72 | [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
73 |
74 | NSString *str = [dateFormatter stringFromDate:self];
75 |
76 | return str;
77 | }
78 |
79 |
80 | @end
81 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0082/XMPPDateTimeProfiles.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "NSDate+XMPPDateTimeProfiles.h"
3 |
4 | @interface XMPPDateTimeProfiles : NSObject
5 |
6 | /**
7 | * The following methods attempt to parse the given string following XEP-0082.
8 | * They return nil if the given string doesn't follow the spec.
9 | **/
10 |
11 | + (NSDate *)parseDate:(NSString *)dateStr;
12 | + (NSDate *)parseTime:(NSString *)timeStr;
13 | + (NSDate *)parseDateTime:(NSString *)dateTimeStr;
14 |
15 | + (NSTimeZone *)parseTimeZoneOffset:(NSString *)tzo;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0085/XMPPMessage+XEP_0085.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPMessage.h"
3 |
4 |
5 | @interface XMPPMessage (XEP_0085)
6 |
7 | - (NSString *)chatState;
8 |
9 | - (BOOL)hasChatState;
10 |
11 | - (BOOL)hasActiveChatState;
12 | - (BOOL)hasComposingChatState;
13 | - (BOOL)hasPausedChatState;
14 | - (BOOL)hasInactiveChatState;
15 | - (BOOL)hasGoneChatState;
16 |
17 | - (void)addActiveChatState;
18 | - (void)addComposingChatState;
19 | - (void)addPausedChatState;
20 | - (void)addInactiveChatState;
21 | - (void)addGoneChatState;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0085/XMPPMessage+XEP_0085.m:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage+XEP_0085.h"
2 | #import "NSXMLElement+XMPP.h"
3 |
4 |
5 | static NSString *const xmlns_chatstates = @"http://jabber.org/protocol/chatstates";
6 |
7 | @implementation XMPPMessage (XEP_0085)
8 |
9 | - (NSString *)chatState{
10 | return [[[self elementsForXmlns:xmlns_chatstates] lastObject] name];
11 | }
12 |
13 | - (BOOL)hasChatState
14 | {
15 | return ([[self elementsForXmlns:xmlns_chatstates] count] > 0);
16 | }
17 |
18 | - (BOOL)hasActiveChatState
19 | {
20 | return ([self elementForName:@"active" xmlns:xmlns_chatstates] != nil);
21 | }
22 |
23 | - (BOOL)hasComposingChatState
24 | {
25 | return ([self elementForName:@"composing" xmlns:xmlns_chatstates] != nil);
26 | }
27 |
28 | - (BOOL)hasPausedChatState
29 | {
30 | return ([self elementForName:@"paused" xmlns:xmlns_chatstates] != nil);
31 | }
32 |
33 | - (BOOL)hasInactiveChatState
34 | {
35 | return ([self elementForName:@"inactive" xmlns:xmlns_chatstates] != nil);
36 | }
37 |
38 | - (BOOL)hasGoneChatState
39 | {
40 | return ([self elementForName:@"gone" xmlns:xmlns_chatstates] != nil);
41 | }
42 |
43 |
44 | - (void)addActiveChatState
45 | {
46 | [self addChild:[NSXMLElement elementWithName:@"active" xmlns:xmlns_chatstates]];
47 | }
48 |
49 | - (void)addComposingChatState
50 | {
51 | [self addChild:[NSXMLElement elementWithName:@"composing" xmlns:xmlns_chatstates]];
52 | }
53 |
54 | - (void)addPausedChatState
55 | {
56 | [self addChild:[NSXMLElement elementWithName:@"paused" xmlns:xmlns_chatstates]];
57 | }
58 |
59 | - (void)addInactiveChatState
60 | {
61 | [self addChild:[NSXMLElement elementWithName:@"inactive" xmlns:xmlns_chatstates]];
62 | }
63 |
64 | - (void)addGoneChatState
65 | {
66 | [self addChild:[NSXMLElement elementWithName:@"gone" xmlns:xmlns_chatstates]];
67 | }
68 |
69 | @end
70 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0092/XMPPSoftwareVersion.h:
--------------------------------------------------------------------------------
1 | #import "XMPPModule.h"
2 |
3 | @interface XMPPSoftwareVersion : XMPPModule
4 |
5 | @property (copy,readonly) NSString *name;
6 | @property (copy,readonly) NSString *version;
7 | @property (copy,readonly) NSString *os;
8 |
9 | - (id)initWithDispatchQueue:(dispatch_queue_t)queue;
10 |
11 | - (id)initWithName:(NSString *)name
12 | version:(NSString *)version
13 | os:(NSString *)os
14 | dispatchQueue:(dispatch_queue_t)queue;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0100/XMPPTransports.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #define _XMPP_TRANSPORTS_H
4 |
5 | @class XMPPStream;
6 |
7 |
8 | @interface XMPPTransports : NSObject
9 | {
10 | XMPPStream *xmppStream;
11 | }
12 |
13 | - (id)initWithStream:(XMPPStream *)xmppStream;
14 |
15 | @property (nonatomic, strong, readonly) XMPPStream *xmppStream;
16 |
17 | - (void)queryGatewayDiscoveryIdentityForLegacyService:(NSString *)service;
18 | - (void)queryGatewayAgentInfo;
19 | - (void)queryRegistrationRequirementsForLegacyService:(NSString *)service;
20 | - (void)registerLegacyService:(NSString *)service username:(NSString *)username password:(NSString *)password;
21 | - (void)unregisterLegacyService:(NSString *)service;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0106/NSString+XEP_0106.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface NSString (XEP_0106)
4 |
5 | - (NSString *)jidEscapedString;
6 |
7 | - (NSString *)jidUnescapedString;
8 |
9 | @end
10 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0115/CoreDataStorage/XMPPCapabilities.xcdatamodel/elements:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/XMPP/Extensions/XEP-0115/CoreDataStorage/XMPPCapabilities.xcdatamodel/elements
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0115/CoreDataStorage/XMPPCapabilities.xcdatamodel/layout:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/XMPP/Extensions/XEP-0115/CoreDataStorage/XMPPCapabilities.xcdatamodel/layout
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0115/CoreDataStorage/XMPPCapabilitiesCoreDataStorage.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import "XMPPCapabilities.h"
5 | #import "XMPPCoreDataStorage.h"
6 |
7 | /**
8 | * This class is an example implementation of XMPPCapabilitiesStorage using core data.
9 | * You are free to substitute your own storage class.
10 | **/
11 |
12 | @interface XMPPCapabilitiesCoreDataStorage : XMPPCoreDataStorage
13 | {
14 | /* Inherited protected variables from XMPPCoreDataStorage
15 |
16 | NSString *databaseFileName;
17 | NSUInteger saveThreshold;
18 |
19 | dispatch_queue_t storageQueue;
20 |
21 | */
22 | }
23 |
24 | /**
25 | * XEP-0115 provides a mechanism for hashing a list of capabilities.
26 | * Clients then broadcast this hash instead of the entire list to save bandwidth.
27 | * Because the hashing is standardized, it is safe to persistently store the linked hash & capabilities.
28 | *
29 | * For this reason, it is recommended you use this sharedInstance across all your xmppStreams.
30 | * This way all streams can shared a knowledgebase concerning known hashes.
31 | *
32 | * All other aspects of capabilities handling (such as JID's, lookup failures, etc) are kept separate between streams.
33 | **/
34 | + (instancetype)sharedInstance;
35 |
36 |
37 | /* Inherited from XMPPCoreDataStorage
38 | * Please see the XMPPCoreDataStorage header file for extensive documentation.
39 |
40 | - (id)initWithDatabaseFilename:(NSString *)databaseFileName storeOptions:(NSDictionary *)storeOptions;
41 | - (id)initWithInMemoryStore;
42 |
43 | @property (readonly) NSString *databaseFileName;
44 |
45 | @property (readwrite) NSUInteger saveThreshold;
46 |
47 | @property (readonly) NSManagedObjectModel *managedObjectModel;
48 | @property (readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
49 |
50 | @property (readonly) NSManagedObjectContext *mainThreadManagedObjectContext;
51 |
52 | */
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0115/CoreDataStorage/XMPPCapsCoreDataStorageObject.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #if TARGET_OS_IPHONE
4 | #import "DDXML.h"
5 | #endif
6 |
7 | @class XMPPCapsResourceCoreDataStorageObject;
8 |
9 |
10 | @interface XMPPCapsCoreDataStorageObject : NSManagedObject
11 |
12 | @property (nonatomic, strong) NSXMLElement *capabilities;
13 |
14 | @property (nonatomic, strong) NSString * hashStr;
15 | @property (nonatomic, strong) NSString * hashAlgorithm;
16 | @property (nonatomic, strong) NSString * capabilitiesStr;
17 |
18 | @property (nonatomic, strong) NSSet * resources;
19 |
20 | @end
21 |
22 |
23 | @interface XMPPCapsCoreDataStorageObject (CoreDataGeneratedAccessors)
24 |
25 | - (void)addResourcesObject:(XMPPCapsResourceCoreDataStorageObject *)value;
26 | - (void)removeResourcesObject:(XMPPCapsResourceCoreDataStorageObject *)value;
27 | - (void)addResources:(NSSet *)value;
28 | - (void)removeResources:(NSSet *)value;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0115/CoreDataStorage/XMPPCapsCoreDataStorageObject.m:
--------------------------------------------------------------------------------
1 | #import "XMPPCapsCoreDataStorageObject.h"
2 | #import "XMPPCapsResourceCoreDataStorageObject.h"
3 | #import "XMPP.h"
4 |
5 | #if ! __has_feature(objc_arc)
6 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
7 | #endif
8 |
9 |
10 | @implementation XMPPCapsCoreDataStorageObject
11 |
12 | @dynamic capabilities;
13 |
14 | @dynamic hashStr;
15 | @dynamic hashAlgorithm;
16 | @dynamic capabilitiesStr;
17 |
18 | @dynamic resources;
19 |
20 | - (NSXMLElement *)capabilities
21 | {
22 | return [[NSXMLElement alloc] initWithXMLString:[self capabilitiesStr] error:nil];
23 | }
24 |
25 | - (void)setCapabilities:(NSXMLElement *)caps
26 | {
27 | self.capabilitiesStr = [caps compactXMLString];
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0115/CoreDataStorage/XMPPCapsResourceCoreDataStorageObject.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @class XMPPCapsCoreDataStorageObject;
4 |
5 |
6 | @interface XMPPCapsResourceCoreDataStorageObject : NSManagedObject
7 |
8 | @property (nonatomic, strong) NSString * jidStr;
9 | @property (nonatomic, strong) NSString * streamBareJidStr;
10 |
11 | @property (nonatomic, assign) BOOL haveFailed;
12 | @property (nonatomic, strong) NSNumber * failed;
13 |
14 | @property (nonatomic, strong) NSString * node;
15 | @property (nonatomic, strong) NSString * ver;
16 | @property (nonatomic, strong) NSString * ext;
17 |
18 | @property (nonatomic, strong) NSString * hashStr;
19 | @property (nonatomic, strong) NSString * hashAlgorithm;
20 |
21 | @property (nonatomic, strong) XMPPCapsCoreDataStorageObject * caps;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0115/CoreDataStorage/XMPPCapsResourceCoreDataStorageObject.m:
--------------------------------------------------------------------------------
1 | #import "XMPPCapsResourceCoreDataStorageObject.h"
2 | #import "XMPPCapsCoreDataStorageObject.h"
3 |
4 | #if ! __has_feature(objc_arc)
5 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
6 | #endif
7 |
8 |
9 | @implementation XMPPCapsResourceCoreDataStorageObject
10 |
11 | @dynamic jidStr;
12 | @dynamic streamBareJidStr;
13 |
14 | @dynamic haveFailed;
15 | @dynamic failed;
16 |
17 | @dynamic node;
18 | @dynamic ver;
19 | @dynamic ext;
20 |
21 | @dynamic hashStr;
22 | @dynamic hashAlgorithm;
23 |
24 | @dynamic caps;
25 |
26 | - (BOOL)haveFailed
27 | {
28 | return [[self failed] boolValue];
29 | }
30 |
31 | - (void)setHaveFailed:(BOOL)flag
32 | {
33 | self.failed = @(flag);
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0136/CoreDataStorage/XMPPMessageArchiving.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | XMPPMessageArchiving.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0136/CoreDataStorage/XMPPMessageArchiving.xcdatamodeld/XMPPMessageArchiving.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0136/CoreDataStorage/XMPPMessageArchivingCoreDataStorage.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "XMPPCoreDataStorage.h"
4 | #import "XMPPMessageArchiving.h"
5 | #import "XMPPMessageArchiving_Message_CoreDataObject.h"
6 | #import "XMPPMessageArchiving_Contact_CoreDataObject.h"
7 |
8 |
9 | @interface XMPPMessageArchivingCoreDataStorage : XMPPCoreDataStorage
10 | {
11 | /* Inherited protected variables from XMPPCoreDataStorage
12 |
13 | NSString *databaseFileName;
14 | NSUInteger saveThreshold;
15 |
16 | dispatch_queue_t storageQueue;
17 |
18 | */
19 | }
20 |
21 | /**
22 | * Convenience method to get an instance with the default database name.
23 | *
24 | * IMPORTANT:
25 | * You are NOT required to use the sharedInstance.
26 | *
27 | * If your application uses multiple xmppStreams, and you use a sharedInstance of this class,
28 | * then all of your streams share the same database store. You might get better performance if you create
29 | * multiple instances of this class instead (using different database filenames), as this way you can have
30 | * concurrent writes to multiple databases.
31 | **/
32 | + (instancetype)sharedInstance;
33 |
34 |
35 | @property (strong) NSString *messageEntityName;
36 | @property (strong) NSString *contactEntityName;
37 |
38 | - (NSEntityDescription *)messageEntity:(NSManagedObjectContext *)moc;
39 | - (NSEntityDescription *)contactEntity:(NSManagedObjectContext *)moc;
40 |
41 | - (XMPPMessageArchiving_Contact_CoreDataObject *)contactForMessage:(XMPPMessageArchiving_Message_CoreDataObject *)msg;
42 |
43 | - (XMPPMessageArchiving_Contact_CoreDataObject *)contactWithJid:(XMPPJID *)contactJid
44 | streamJid:(XMPPJID *)streamJid
45 | managedObjectContext:(NSManagedObjectContext *)moc;
46 |
47 | - (XMPPMessageArchiving_Contact_CoreDataObject *)contactWithBareJidStr:(NSString *)contactBareJidStr
48 | streamBareJidStr:(NSString *)streamBareJidStr
49 | managedObjectContext:(NSManagedObjectContext *)moc;
50 |
51 | /* Inherited from XMPPCoreDataStorage
52 | * Please see the XMPPCoreDataStorage header file for extensive documentation.
53 |
54 | - (id)initWithDatabaseFilename:(NSString *)databaseFileName storeOptions:(NSDictionary *)storeOptions;
55 | - (id)initWithInMemoryStore;
56 |
57 | @property (readonly) NSString *databaseFileName;
58 |
59 | @property (readwrite) NSUInteger saveThreshold;
60 |
61 | @property (readonly) NSManagedObjectModel *managedObjectModel;
62 | @property (readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
63 |
64 | @property (readonly) NSManagedObjectContext *mainThreadManagedObjectContext;
65 |
66 | */
67 |
68 | @end
69 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0136/CoreDataStorage/XMPPMessageArchiving_Contact_CoreDataObject.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "XMPP.h"
4 |
5 |
6 | @interface XMPPMessageArchiving_Contact_CoreDataObject : NSManagedObject
7 |
8 | @property (nonatomic, strong) XMPPJID * bareJid; // Transient (proper type, not on disk)
9 | @property (nonatomic, strong) NSString * bareJidStr; // Shadow (binary data, written to disk)
10 |
11 | @property (nonatomic, strong) NSDate * mostRecentMessageTimestamp;
12 | @property (nonatomic, strong) NSString * mostRecentMessageBody;
13 | @property (nonatomic, strong) NSNumber * mostRecentMessageOutgoing;
14 |
15 | @property (nonatomic, strong) NSString * streamBareJidStr;
16 |
17 | /**
18 | * This method is called immediately before the object is inserted into the managedObjectContext.
19 | * At this point, all normal properties have been set.
20 | *
21 | * If you extend XMPPMessageArchiving_Contact_CoreDataObject,
22 | * you can use this method as a hook to set your custom properties.
23 | **/
24 | - (void)willInsertObject;
25 |
26 | /**
27 | * This method is called after any properties on the object have been updated,
28 | * due to a message being added to the conversation.
29 | * At this point, any changed properties have been updated.
30 | *
31 | * If you extend XMPPMessageArchiving_Contact_CoreDataObject,
32 | * you can use this method as a hook to update your custom properties.
33 | **/
34 | - (void)didUpdateObject;
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0136/CoreDataStorage/XMPPMessageArchiving_Contact_CoreDataObject.m:
--------------------------------------------------------------------------------
1 | #import "XMPPMessageArchiving_Contact_CoreDataObject.h"
2 |
3 |
4 | @interface XMPPMessageArchiving_Contact_CoreDataObject ()
5 |
6 | @property (nonatomic, strong) XMPPJID * primitiveBareJid;
7 | @property (nonatomic, strong) NSString * primitiveBareJidStr;
8 |
9 | @end
10 |
11 |
12 | @implementation XMPPMessageArchiving_Contact_CoreDataObject
13 |
14 | @dynamic bareJid, primitiveBareJid;
15 | @dynamic bareJidStr, primitiveBareJidStr;
16 | @dynamic mostRecentMessageTimestamp;
17 | @dynamic mostRecentMessageBody;
18 | @dynamic mostRecentMessageOutgoing;
19 | @dynamic streamBareJidStr;
20 |
21 | #pragma mark Transient bareJid
22 |
23 | - (XMPPJID *)bareJid
24 | {
25 | // Create and cache on demand
26 |
27 | [self willAccessValueForKey:@"bareJid"];
28 | XMPPJID *tmp = self.primitiveBareJid;
29 | [self didAccessValueForKey:@"bareJid"];
30 |
31 | if (tmp == nil)
32 | {
33 | NSString *bareJidStr = self.bareJidStr;
34 | if (bareJidStr)
35 | {
36 | tmp = [XMPPJID jidWithString:bareJidStr];
37 | self.primitiveBareJid = tmp;
38 | }
39 | }
40 |
41 | return tmp;
42 | }
43 |
44 | - (void)setBareJid:(XMPPJID *)bareJid
45 | {
46 | if ([self.bareJid isEqualToJID:bareJid options:XMPPJIDCompareBare])
47 | {
48 | return; // No change
49 | }
50 |
51 | [self willChangeValueForKey:@"bareJid"];
52 | [self willChangeValueForKey:@"bareJidStr"];
53 |
54 | self.primitiveBareJid = [bareJid bareJID];
55 | self.primitiveBareJidStr = [bareJid bare];
56 |
57 | [self didChangeValueForKey:@"bareJid"];
58 | [self didChangeValueForKey:@"bareJidStr"];
59 | }
60 |
61 | - (void)setBareJidStr:(NSString *)bareJidStr
62 | {
63 | if ([self.bareJidStr isEqualToString:bareJidStr])
64 | {
65 | return; // No change
66 | }
67 |
68 | [self willChangeValueForKey:@"bareJid"];
69 | [self willChangeValueForKey:@"bareJidStr"];
70 |
71 | XMPPJID *bareJid = [[XMPPJID jidWithString:bareJidStr] bareJID];
72 |
73 | self.primitiveBareJid = bareJid;
74 | self.primitiveBareJidStr = [bareJid bare];
75 |
76 | [self didChangeValueForKey:@"bareJid"];
77 | [self didChangeValueForKey:@"bareJidStr"];
78 | }
79 |
80 | #pragma mark Hooks
81 |
82 | - (void)willInsertObject
83 | {
84 | // If you extend XMPPMessageArchiving_Contact_CoreDataObject,
85 | // you can override this method to use as a hook to set your own custom properties.
86 | }
87 |
88 | - (void)didUpdateObject
89 | {
90 | // If you extend XMPPMessageArchiving_Contact_CoreDataObject,
91 | // you can override this method to use as a hook to update your own custom properties.
92 | }
93 |
94 | @end
95 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0136/CoreDataStorage/XMPPMessageArchiving_Message_CoreDataObject.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "XMPP.h"
4 |
5 |
6 | @interface XMPPMessageArchiving_Message_CoreDataObject : NSManagedObject
7 |
8 | @property (nonatomic, strong) XMPPMessage * message; // Transient (proper type, not on disk)
9 | @property (nonatomic, strong) NSString * messageStr; // Shadow (binary data, written to disk)
10 |
11 | /**
12 | * This is the bare jid of the person you're having the conversation with.
13 | * For example: robbiehanson@deusty.com
14 | *
15 | * Regardless of whether the message was incoming or outgoing,
16 | * this will represent the "other" participant in the conversation.
17 | **/
18 | @property (nonatomic, strong) XMPPJID * bareJid; // Transient (proper type, not on disk)
19 | @property (nonatomic, strong) NSString * bareJidStr; // Shadow (binary data, written to disk)
20 |
21 | @property (nonatomic, strong) NSString * body;
22 | @property (nonatomic, strong) NSString * thread;
23 |
24 | @property (nonatomic, strong) NSNumber * outgoing; // Use isOutgoing
25 | @property (nonatomic, assign) BOOL isOutgoing; // Convenience property
26 |
27 | @property (nonatomic, strong) NSNumber * composing; // Use isComposing
28 | @property (nonatomic, assign) BOOL isComposing; // Convenience property
29 |
30 | @property (nonatomic, strong) NSDate * timestamp;
31 |
32 | @property (nonatomic, strong) NSString * streamBareJidStr;
33 |
34 | /**
35 | * This method is called immediately before the object is inserted into the managedObjectContext.
36 | * At this point, all normal properties have been set.
37 | *
38 | * If you extend XMPPMessageArchiving_Message_CoreDataObject,
39 | * you can use this method as a hook to set your custom properties.
40 | **/
41 | - (void)willInsertObject;
42 |
43 | /**
44 | * This method is called immediately after the message has been changed.
45 | * At this point, all normal properties have been updated.
46 | *
47 | * If you extend XMPPMessageArchiving_Message_CoreDataObject,
48 | * you can use this method as a hook to set your custom properties.
49 | **/
50 | - (void)didUpdateObject;
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0172/XMPPMessage+XEP_0172.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPMessage.h"
3 |
4 | @interface XMPPMessage (XEP_0172)
5 |
6 | - (NSString *)nick;
7 |
8 | @end
9 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0172/XMPPMessage+XEP_0172.m:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage+XEP_0172.h"
2 | #import "NSXMLElement+XMPP.h"
3 |
4 | #define XMLNS_NICK @"http://jabber.org/protocol/nick"
5 |
6 | @implementation XMPPMessage (XEP_0172)
7 |
8 | - (NSString *)nick
9 | {
10 | return [[self elementForName:@"nick" xmlns:XMLNS_NICK] stringValue];
11 | }
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0172/XMPPPresence+XEP_0172.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPPresence.h"
3 |
4 | @interface XMPPPresence (XEP_0172)
5 |
6 | - (NSString *)nick;
7 |
8 | @end
9 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0172/XMPPPresence+XEP_0172.m:
--------------------------------------------------------------------------------
1 | #import "XMPPPresence+XEP_0172.h"
2 | #import "NSXMLElement+XMPP.h"
3 |
4 | #define XMLNS_NICK @"http://jabber.org/protocol/nick"
5 |
6 | @implementation XMPPPresence (XEP_0172)
7 |
8 | - (NSString *)nick{
9 | return [[self elementForName:@"nick" xmlns:XMLNS_NICK] stringValue];
10 | }
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0184/XMPPMessage+XEP_0184.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPMessage.h"
3 |
4 |
5 | @interface XMPPMessage (XEP_0184)
6 |
7 | - (BOOL)hasReceiptRequest;
8 | - (BOOL)hasReceiptResponse;
9 | - (NSString *)receiptResponseID;
10 | - (XMPPMessage *)generateReceiptResponse;
11 |
12 | - (void)addReceiptRequest;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0184/XMPPMessage+XEP_0184.m:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage+XEP_0184.h"
2 | #import "NSXMLElement+XMPP.h"
3 |
4 |
5 | @implementation XMPPMessage (XEP_0184)
6 |
7 | - (BOOL)hasReceiptRequest
8 | {
9 | NSXMLElement *receiptRequest = [self elementForName:@"request" xmlns:@"urn:xmpp:receipts"];
10 |
11 | return (receiptRequest != nil);
12 | }
13 |
14 | - (BOOL)hasReceiptResponse
15 | {
16 | NSXMLElement *receiptResponse = [self elementForName:@"received" xmlns:@"urn:xmpp:receipts"];
17 |
18 | return (receiptResponse != nil);
19 | }
20 |
21 | - (NSString *)receiptResponseID
22 | {
23 | NSXMLElement *receiptResponse = [self elementForName:@"received" xmlns:@"urn:xmpp:receipts"];
24 |
25 | return [receiptResponse attributeStringValueForName:@"id"];
26 | }
27 |
28 | - (XMPPMessage *)generateReceiptResponse
29 | {
30 | // Example:
31 | //
32 | //
33 | //
34 | //
35 |
36 | NSXMLElement *received = [NSXMLElement elementWithName:@"received" xmlns:@"urn:xmpp:receipts"];
37 |
38 | NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
39 |
40 | NSString *to = [self fromStr];
41 | if (to)
42 | {
43 | [message addAttributeWithName:@"to" stringValue:to];
44 | }
45 |
46 | NSString *msgid = [self elementID];
47 | if (msgid)
48 | {
49 | [received addAttributeWithName:@"id" stringValue:msgid];
50 | }
51 |
52 | [message addChild:received];
53 |
54 | return [[self class] messageFromElement:message];
55 | }
56 |
57 |
58 | - (void)addReceiptRequest
59 | {
60 | NSXMLElement *receiptRequest = [NSXMLElement elementWithName:@"request" xmlns:@"urn:xmpp:receipts"];
61 | [self addChild:receiptRequest];
62 | }
63 |
64 | @end
65 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0184/XMPPMessageDeliveryReceipts.h:
--------------------------------------------------------------------------------
1 | #import "XMPPModule.h"
2 |
3 | #define _XMPP_MESSAGE_DELIVERY_RECEIPTS_H
4 |
5 | /**
6 | * XMPPMessageDeliveryReceipts can be configured to automatically send delivery receipts and requests in accordance to XEP-0184
7 | **/
8 |
9 | @interface XMPPMessageDeliveryReceipts : XMPPModule
10 |
11 | /**
12 | * Automatically add message delivery requests to outgoing messages, in all situations that are permitted in XEP-0184
13 | *
14 | * - Message MUST NOT be of type 'error' or 'groupchat'
15 | * - Message MUST have an id
16 | * - Message MUST NOT have a delivery receipt or request
17 | * - To must either be a bare JID or a full JID that advertises the urn:xmpp:receipts capability
18 | *
19 | * Default NO
20 | **/
21 |
22 | @property (assign) BOOL autoSendMessageDeliveryRequests;
23 |
24 | /**
25 | * Automatically send message delivery receipts when a message with a delivery request is received
26 | *
27 | * Default NO
28 | **/
29 |
30 | @property (assign) BOOL autoSendMessageDeliveryReceipts;
31 |
32 | @end
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0198/Memory Storage/XMPPStreamManagementMemoryStorage.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPStreamManagement.h"
3 |
4 | /**
5 | * This class provides an in-memory only storage system for XMPPStreamManagement.
6 | * As such, it will only support stream resumption so long as the application doesn't terminate.
7 | *
8 | * This class should be considered primarily for testing.
9 | * An application making use of stream management should likely transition
10 | * to a persistent storage layer before distribution.
11 | **/
12 | @interface XMPPStreamManagementMemoryStorage : NSObject
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0198/Private/XMPPStreamManagementStanzas.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPPElement.h"
3 |
4 | /**
5 | * An outgoing stanza.
6 | *
7 | * The translation from element to stanzaId may be an asynchronous process,
8 | * so this structure is used to assist in the process.
9 | **/
10 | @interface XMPPStreamManagementOutgoingStanza : NSObject
11 |
12 | - (instancetype)initAwaitingStanzaId;
13 | - (instancetype)initWithStanzaId:(id)stanzaId;
14 |
15 | @property (nonatomic, strong, readwrite) id stanzaId;
16 | @property (nonatomic, assign, readwrite) BOOL awaitingStanzaId;
17 |
18 | @end
19 |
20 | #pragma mark -
21 |
22 | /**
23 | * An incoming stanza.
24 | *
25 | * The translation from element to stanzaId may be an asynchronous process,
26 | * so this structure is used to assist in the process.
27 | **/
28 | @interface XMPPStreamManagementIncomingStanza : NSObject
29 |
30 | - (instancetype)initWithStanzaId:(id)stanzaId isHandled:(BOOL)isHandled;
31 |
32 | @property (nonatomic, strong, readwrite) id stanzaId;
33 | @property (nonatomic, assign, readwrite) BOOL isHandled;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0198/Private/XMPPStreamManagementStanzas.m:
--------------------------------------------------------------------------------
1 | #import "XMPPStreamManagementStanzas.h"
2 |
3 |
4 | @implementation XMPPStreamManagementOutgoingStanza
5 |
6 | @synthesize awaitingStanzaId = awaitingStanzaId;
7 | @synthesize stanzaId = stanzaId;
8 |
9 | /**
10 | * Use when the stanzaId is unknown, and we are awaiting a stanzaId from the delegate(s).
11 | **/
12 | - (instancetype)initAwaitingStanzaId
13 | {
14 | if ((self = [super init]))
15 | {
16 | awaitingStanzaId = YES;
17 | }
18 | return self;
19 | }
20 |
21 | /**
22 | * Use when the stanzaId is known, meaning we are NOT awaiting a stanzaId from the delegate(s).
23 | * The stanzaId may be nil.
24 | **/
25 | - (instancetype)initWithStanzaId:(id)inStanzaId
26 | {
27 | if ((self = [super init]))
28 | {
29 | stanzaId = inStanzaId;
30 | awaitingStanzaId = NO;
31 | }
32 | return self;
33 | }
34 |
35 | /* NSCopying */
36 |
37 | - (id)copyWithZone:(NSZone *)zone
38 | {
39 | XMPPStreamManagementOutgoingStanza *copy = [[XMPPStreamManagementOutgoingStanza alloc] init];
40 | copy->awaitingStanzaId = awaitingStanzaId;
41 | copy->stanzaId = stanzaId;
42 |
43 | return copy;
44 | }
45 |
46 | /* NSCoding */
47 |
48 | - (id)initWithCoder:(NSCoder *)decoder
49 | {
50 | if ((self = [super init]))
51 | {
52 | awaitingStanzaId = [decoder decodeBoolForKey:@"awaitingStanzaId"];
53 | stanzaId = [decoder decodeObjectForKey:@"stanzaId"];
54 | }
55 | return self;
56 | }
57 |
58 | - (void)encodeWithCoder:(NSCoder *)coder
59 | {
60 | [coder encodeBool:awaitingStanzaId forKey:@"awaitingStanzaId"];
61 | [coder encodeObject:stanzaId forKey:@"stanzaId"];
62 | }
63 |
64 | @end
65 |
66 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
67 | #pragma mark -
68 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
69 |
70 | @implementation XMPPStreamManagementIncomingStanza
71 |
72 | @synthesize stanzaId = stanzaId;
73 | @synthesize isHandled = isHandled;
74 |
75 | - (instancetype)initWithStanzaId:(id)inStanzaId isHandled:(BOOL)inIsHandled
76 | {
77 | if ((self = [super init]))
78 | {
79 | stanzaId = inStanzaId;
80 | isHandled = inIsHandled;
81 | }
82 | return self;
83 | }
84 |
85 | @end
86 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0199/XMPPPing.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "XMPP.h"
3 |
4 | #define _XMPP_PING_H
5 |
6 | @class XMPPIDTracker;
7 |
8 |
9 | @interface XMPPPing : XMPPModule
10 | {
11 | BOOL respondsToQueries;
12 | XMPPIDTracker *pingTracker;
13 | }
14 |
15 | /**
16 | * Whether or not the module should respond to incoming ping queries.
17 | * It you create multiple instances of this module, only one instance should respond to queries.
18 | *
19 | * It is recommended you set this (if needed) before you activate the module.
20 | * The default value is YES.
21 | **/
22 | @property (readwrite) BOOL respondsToQueries;
23 |
24 | /**
25 | * Send pings to the server or a specific JID.
26 | * The disco module may be used to detect if the target supports ping.
27 | *
28 | * The returned string is the pingID (the elementID of the query that was sent).
29 | * In other words:
30 | *
31 | * SEND:
32 | * RECV:
33 | *
34 | * This may be helpful if you are sending multiple simultaneous pings to the same target.
35 | **/
36 | - (NSString *)sendPingToServer;
37 | - (NSString *)sendPingToServerWithTimeout:(NSTimeInterval)timeout;
38 | - (NSString *)sendPingToJID:(XMPPJID *)jid;
39 | - (NSString *)sendPingToJID:(XMPPJID *)jid withTimeout:(NSTimeInterval)timeout;
40 |
41 | @end
42 |
43 | @protocol XMPPPingDelegate
44 | @optional
45 |
46 | - (void)xmppPing:(XMPPPing *)sender didReceivePong:(XMPPIQ *)pong withRTT:(NSTimeInterval)rtt;
47 | - (void)xmppPing:(XMPPPing *)sender didNotReceivePong:(NSString *)pingID dueToTimeout:(NSTimeInterval)timeout;
48 |
49 | // Note: If the xmpp stream is disconnected, no delegate methods will be called, and outstanding pings are forgotten.
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0203/NSXMLElement+XEP_0203.h:
--------------------------------------------------------------------------------
1 | #import
2 | #if TARGET_OS_IPHONE
3 | #import "DDXML.h"
4 | #endif
5 |
6 |
7 | @interface NSXMLElement (XEP_0203)
8 |
9 | - (BOOL)wasDelayed;
10 | - (NSDate *)delayedDeliveryDate;
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0203/NSXMLElement+XEP_0203.m:
--------------------------------------------------------------------------------
1 | #import "NSXMLElement+XEP_0203.h"
2 | #import "XMPPDateTimeProfiles.h"
3 | #import "NSXMLElement+XMPP.h"
4 |
5 | #if ! __has_feature(objc_arc)
6 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
7 | #endif
8 |
9 | @implementation NSXMLElement (XEP_0203)
10 |
11 | - (BOOL)wasDelayed
12 | {
13 | NSXMLElement *delay;
14 |
15 | delay = [self elementForName:@"delay" xmlns:@"urn:xmpp:delay"];
16 | if (delay)
17 | {
18 | return YES;
19 | }
20 |
21 | delay = [self elementForName:@"x" xmlns:@"jabber:x:delay"];
22 | if (delay)
23 | {
24 | return YES;
25 | }
26 |
27 | return NO;
28 | }
29 |
30 | - (NSDate *)delayedDeliveryDate
31 | {
32 | NSXMLElement *delay;
33 |
34 | // From XEP-0203 (Delayed Delivery)
35 | //
36 | //
39 | //
40 | // The format [of the stamp attribute] MUST adhere to the dateTime format
41 | // specified in XEP-0082 and MUST be expressed in UTC.
42 |
43 | delay = [self elementForName:@"delay" xmlns:@"urn:xmpp:delay"];
44 | if (delay)
45 | {
46 | NSString *stampValue = [delay attributeStringValueForName:@"stamp"];
47 |
48 | // There are other considerations concerning XEP-0082.
49 | // For example, it may optionally contain milliseconds.
50 | // And it may possibly express UTC as "+00:00" instead of "Z".
51 | //
52 | // Thankfully there is already an implementation that takes into account all these possibilities.
53 |
54 | return [XMPPDateTimeProfiles parseDateTime:stampValue];
55 | }
56 |
57 | // From XEP-0091 (Legacy Delayed Delivery)
58 | //
59 | //
62 |
63 | delay = [self elementForName:@"x" xmlns:@"jabber:x:delay"];
64 | if (delay)
65 | {
66 | NSDate *stamp;
67 |
68 | NSString *stampValue = [delay attributeStringValueForName:@"stamp"];
69 |
70 | NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
71 | [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
72 | [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
73 | [dateFormatter setDateFormat:@"yyyyMMdd'T'HH:mm:ss"];
74 | [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
75 |
76 | stamp = [dateFormatter dateFromString:stampValue];
77 |
78 | return stamp;
79 | }
80 |
81 | return nil;
82 | }
83 |
84 | @end
85 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0223/XEP_0223.h:
--------------------------------------------------------------------------------
1 | /**
2 | * XEP-0223 : Persistent Storage of Private Data via PubSub
3 | *
4 | * This specification defines best practices for using the XMPP publish-subscribe extension to
5 | * persistently store private information such as bookmarks and client configuration options.
6 | *
7 | * http://xmpp.org/extensions/xep-0223.html
8 | **/
9 |
10 | #import
11 |
12 |
13 | @interface XEP_0223 : NSObject
14 |
15 | /**
16 | * This method returns the recommended configuration options to configure a pubsub node for storing private data.
17 | * It may be passed directly to the publishToNoe:::: method of XMPPPubSub.
18 | **/
19 | + (NSDictionary *)privateStoragePubSubOptions;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0223/XEP_0223.m:
--------------------------------------------------------------------------------
1 | /**
2 | * XEP-0223 : Persistent Storage of Private Data via PubSub
3 | *
4 | * This specification defines best practices for using the XMPP publish-subscribe extension to
5 | * persistently store private information such as bookmarks and client configuration options.
6 | *
7 | * http://xmpp.org/extensions/xep-0223.html
8 | **/
9 |
10 | #import "XEP_0223.h"
11 |
12 | @implementation XEP_0223
13 |
14 | + (NSDictionary *)privateStoragePubSubOptions
15 | {
16 | return @{ @"pubsub#persist_items" : @(YES),
17 | @"pubsub#access_model" : @"whitelist" };
18 | }
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0224/XMPPAttentionModule.h:
--------------------------------------------------------------------------------
1 | #import "XMPPModule.h"
2 | #import "XMPPMessage+XEP_0224.h"
3 |
4 | #define _XMPP_ATTENTION_MODULE_H
5 |
6 | @interface XMPPAttentionModule : XMPPModule {
7 | BOOL respondsToQueries;
8 | }
9 |
10 | /**
11 | * Whether or not the module should respond to incoming attention request queries.
12 | * It you create multiple instances of this module, only one instance should respond to queries.
13 | *
14 | * It is recommended you set this (if needed) before you activate the module.
15 | * The default value is YES.
16 | **/
17 | @property (readwrite) BOOL respondsToQueries;
18 |
19 | @end
20 |
21 | @protocol XMPPAttentionDelegate
22 | @optional
23 | - (void)xmppAttention:(XMPPAttentionModule *)sender didReceiveAttentionHeadlineMessage:(XMPPMessage *)attentionRequest;
24 | @end
25 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0224/XMPPMessage+XEP_0224.h:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage.h"
2 | #define XMLNS_ATTENTION @"urn:xmpp:attention:0"
3 |
4 | @interface XMPPMessage (XEP_0224)
5 | - (BOOL)isHeadLineMessage;
6 | - (BOOL)isAttentionMessage;
7 | - (BOOL)isAttentionMessageWithBody;
8 | @end
9 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0224/XMPPMessage+XEP_0224.m:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage+XEP_0224.h"
2 | #import "NSXMLElement+XMPP.h"
3 |
4 | @implementation XMPPMessage (XEP_0224)
5 |
6 | - (BOOL)isHeadLineMessage {
7 | return [[[self attributeForName:@"type"] stringValue] isEqualToString:@"headline"];
8 | }
9 |
10 | - (BOOL)isAttentionMessage
11 | {
12 | return [self isHeadLineMessage] && [self elementForName:@"attention" xmlns:XMLNS_ATTENTION];
13 | }
14 |
15 | - (BOOL)isAttentionMessageWithBody
16 | {
17 | if([self isAttentionMessage])
18 | {
19 | return [self isMessageWithBody];
20 | }
21 | return NO;
22 | }
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0280/XMPPMessage+XEP_0280.h:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage.h"
2 | @class XMPPJID;
3 |
4 | @interface XMPPMessage (XEP_0280)
5 |
6 | - (NSXMLElement *)receivedMessageCarbon;
7 | - (NSXMLElement *)sentMessageCarbon;
8 |
9 | - (BOOL)isMessageCarbon;
10 | - (BOOL)isReceivedMessageCarbon;
11 | - (BOOL)isSentMessageCarbon;
12 | - (BOOL)isTrustedMessageCarbon;
13 | - (BOOL)isTrustedMessageCarbonForMyJID:(XMPPJID *)jid;
14 |
15 | - (XMPPMessage *)messageCarbonForwardedMessage;
16 |
17 | - (void)addPrivateMessageCarbons;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0280/XMPPMessageCarbons.h:
--------------------------------------------------------------------------------
1 | #import "XMPPModule.h"
2 | @class XMPPMessage;
3 | @class XMPPIDTracker;
4 |
5 | #define _XMPP_MESSAGE_CARBONS_H
6 |
7 | @interface XMPPMessageCarbons : XMPPModule
8 | {
9 | BOOL autoEnableMessageCarbons;
10 | BOOL allowsUntrustedMessageCarbons;
11 | BOOL messageCarbonsEnabled;
12 |
13 | XMPPIDTracker *xmppIDTracker;
14 | }
15 |
16 | /**
17 | * Wether or not to automatically enable Message Carbons.
18 | *
19 | * Default YES
20 | **/
21 | @property (assign) BOOL autoEnableMessageCarbons;
22 |
23 | /**
24 | * Wether Message Carbons is currently enabled or not.
25 | *
26 | * @see enableMessageCarbons
27 | * @see disableMessageCarbons
28 | **/
29 | @property (assign, getter = isMessageCarbonsEnabled,readonly) BOOL messageCarbonsEnabled;
30 |
31 | /**
32 | * Whether Message Carbons are validated before calling the delegate methods.
33 | *
34 | * @see xmppMessageCarbons:willReceiveMessage:outgoing:
35 | * @see xmppMessageCarbons:didReceiveMessage:outgoing:
36 | *
37 | * A Message Carbon is Trusted if:
38 | *
39 | * - It is from the Stream's Bare JID
40 | * - Sent Forward Messages are from the Stream's JID
41 | * - Received Forward Messages are to the Stream's JID
42 | *
43 | * Default is NO
44 | **/
45 | @property (assign) BOOL allowsUntrustedMessageCarbons;
46 |
47 | /**
48 | * Enable Message Carbons
49 | **/
50 | - (void)enableMessageCarbons;
51 |
52 | /**
53 | * Disable Message Carbons
54 | **/
55 | - (void)disableMessageCarbons;
56 |
57 | @end
58 |
59 | @protocol XMPPMessageCarbonsDelegate
60 |
61 | - (void)xmppMessageCarbons:(XMPPMessageCarbons *)xmppMessageCarbons willReceiveMessage:(XMPPMessage *)message outgoing:(BOOL)isOutgoing;
62 |
63 | - (void)xmppMessageCarbons:(XMPPMessageCarbons *)xmppMessageCarbons didReceiveMessage:(XMPPMessage *)message outgoing:(BOOL)isOutgoing;
64 |
65 | @end
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0297/NSXMLElement+XEP_0297.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #if TARGET_OS_IPHONE
4 | #import "DDXML.h"
5 | #endif
6 |
7 | @class XMPPIQ;
8 | @class XMPPMessage;
9 | @class XMPPPresence;
10 |
11 | @interface NSXMLElement (XEP_0297)
12 |
13 | #pragma mark Forwarded Stanza
14 |
15 | - (NSXMLElement *)forwardedStanza;
16 |
17 | - (BOOL)hasForwardedStanza;
18 |
19 | - (BOOL)isForwardedStanza;
20 |
21 | #pragma mark Delayed Delivery Date
22 |
23 | - (NSDate *)forwardedStanzaDelayedDeliveryDate;
24 |
25 | #pragma mark XMPPElement
26 |
27 | - (XMPPIQ *)forwardedIQ;
28 |
29 | - (BOOL)hasForwardedIQ;
30 |
31 | - (XMPPMessage *)forwardedMessage;
32 |
33 | - (BOOL)hasForwardedMessage;
34 |
35 | - (XMPPPresence *)forwardedPresence;
36 |
37 | - (BOOL)hasForwardedPresence;
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0308/XMPPMessage+XEP_0308.h:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage.h"
2 |
3 | @interface XMPPMessage (XEP_0308)
4 |
5 | - (BOOL)isMessageCorrection;
6 |
7 | - (NSString *)correctedMessageID;
8 |
9 | - (void)addMessageCorrectionWithID:(NSString *)messageCorrectionID;
10 |
11 | - (XMPPMessage *)generateCorrectionMessageWithID:(NSString *)elementID;
12 | - (XMPPMessage *)generateCorrectionMessageWithID:(NSString *)elementID body:(NSString *)body;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0308/XMPPMessage+XEP_0308.m:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage+XEP_0308.h"
2 | #import "NSXMLElement+XMPP.h"
3 |
4 | #if ! __has_feature(objc_arc)
5 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
6 | #endif
7 |
8 | #define NAME_XMPP_MESSAGE_CORRECT @"replace"
9 | #define XMLNS_XMPP_MESSAGE_CORRECT @"urn:xmpp:message-correct:0"
10 |
11 | @implementation XMPPMessage (XEP_0308)
12 |
13 | - (BOOL)isMessageCorrection
14 | {
15 | if([[self correctedMessageID] length])
16 | {
17 | return YES;
18 | }
19 | else
20 | {
21 | return NO;
22 | }
23 | }
24 |
25 | - (NSString *)correctedMessageID
26 | {
27 | return [[self elementForName:NAME_XMPP_MESSAGE_CORRECT xmlns:XMLNS_XMPP_MESSAGE_CORRECT] attributeStringValueForName:@"id"];
28 | }
29 |
30 | - (void)addMessageCorrectionWithID:(NSString *)messageCorrectionID
31 | {
32 | NSXMLElement *replace = [NSXMLElement elementWithName:NAME_XMPP_MESSAGE_CORRECT stringValue:XMLNS_XMPP_MESSAGE_CORRECT];
33 | [replace addAttributeWithName:@"id" stringValue:messageCorrectionID];
34 | [self addChild:replace];
35 | }
36 |
37 | - (XMPPMessage *)generateCorrectionMessageWithID:(NSString *)elementID
38 | {
39 | XMPPMessage *correctionMessage = nil;
40 |
41 | if([[self elementID] length] && ![self isMessageCorrection])
42 | {
43 | correctionMessage = [self copy];
44 |
45 | [correctionMessage removeAttributeForName:@"id"];
46 |
47 | if([elementID length])
48 | {
49 | [correctionMessage addAttributeWithName:@"id" stringValue:elementID];
50 | }
51 |
52 | [correctionMessage addMessageCorrectionWithID:[self elementID]];
53 | }
54 |
55 | return correctionMessage;
56 | }
57 |
58 | - (XMPPMessage *)generateCorrectionMessageWithID:(NSString *)elementID body:(NSString *)body
59 | {
60 | XMPPMessage *correctionMessage = nil;
61 |
62 | if([[self elementID] length] && ![self isMessageCorrection])
63 | {
64 | correctionMessage = [self copy];
65 |
66 | [correctionMessage removeAttributeForName:@"id"];
67 |
68 | if([elementID length])
69 | {
70 | [correctionMessage addAttributeWithName:@"id" stringValue:elementID];
71 | }
72 |
73 | NSXMLElement *bodyElement = [correctionMessage elementForName:@"body"];
74 |
75 | if(bodyElement)
76 | {
77 | [correctionMessage removeChildAtIndex:[[correctionMessage children] indexOfObject:bodyElement]];
78 | }
79 |
80 | [self addBody:body];
81 |
82 | [correctionMessage addMessageCorrectionWithID:[self elementID]];
83 | }
84 |
85 | return correctionMessage;
86 | }
87 |
88 | @end
89 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0333/XMPPMessage+XEP_0333.h:
--------------------------------------------------------------------------------
1 | #import "XMPPMessage.h"
2 |
3 | @interface XMPPMessage (XEP_0333)
4 |
5 | - (BOOL)hasChatMarker;
6 |
7 | - (BOOL)hasMarkableChatMarker;
8 | - (BOOL)hasReceivedChatMarker;
9 | - (BOOL)hasDisplayedChatMarker;
10 | - (BOOL)hasAcknowledgedChatMarker;
11 |
12 | - (NSString *)chatMarker;
13 | - (NSString *)chatMarkerID;
14 |
15 | - (void)addMarkableChatMarker;
16 | - (void)addReceivedChatMarkerWithID:(NSString *)elementID;
17 | - (void)addDisplayedChatMarkerWithID:(NSString *)elementID;
18 | - (void)addAcknowledgedChatMarkerWithID:(NSString *)elementID;
19 |
20 | - (XMPPMessage *)generateReceivedChatMarker;
21 | - (XMPPMessage *)generateDisplayedChatMarker;
22 | - (XMPPMessage *)generateAcknowledgedChatMarker;
23 |
24 | - (XMPPMessage *)generateReceivedChatMarkerIncludingThread:(BOOL)includingThread;
25 | - (XMPPMessage *)generateDisplayedChatMarkerIncludingThread:(BOOL)includingThread;
26 | - (XMPPMessage *)generateAcknowledgedChatMarkerIncludingThread:(BOOL)includingThread;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0335/NSXMLElement+XEP_0335.h:
--------------------------------------------------------------------------------
1 | #import
2 | #if TARGET_OS_IPHONE
3 | #import "DDXML.h"
4 | #endif
5 |
6 | @interface NSXMLElement (XEP_0335)
7 |
8 | - (NSXMLElement *)JSONContainer;
9 |
10 | - (BOOL)isJSONContainer;
11 | - (BOOL)hasJSONContainer;
12 |
13 | - (NSString *)JSONContainerString;
14 | - (NSData *)JSONContainerData;
15 | - (id)JSONContainerObject;
16 |
17 | - (void)addJSONContainerWithString:(NSString *)JSONContainerString;
18 | - (void)addJSONContainerWithData:(NSData *)JSONContainerData;
19 | - (void)addJSONContainerWithObject:(id)JSONContainerObject;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Extensions/XEP-0335/NSXMLElement+XEP_0335.m:
--------------------------------------------------------------------------------
1 | #import "NSXMLElement+XEP_0335.h"
2 | #import "NSXMLElement+XMPP.h"
3 |
4 | #if ! __has_feature(objc_arc)
5 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
6 | #endif
7 |
8 | #define XEP_0335_NAME @"json"
9 | #define XEP_0335_XMLNS @"urn:xmpp:json:0"
10 |
11 | @implementation NSXMLElement (XEP_0335)
12 |
13 | - (NSXMLElement *)JSONContainer
14 | {
15 | if([self isJSONContainer])
16 | {
17 | return self;
18 | }
19 | else
20 | {
21 | return [self elementForName:XEP_0335_NAME xmlns:XEP_0335_XMLNS];
22 | }
23 | }
24 |
25 | - (BOOL)isJSONContainer
26 | {
27 | if([[self name] isEqualToString:XEP_0335_NAME] && [[self xmlns] isEqualToString:XEP_0335_XMLNS])
28 | {
29 | return YES;
30 | }
31 | else
32 | {
33 | return NO;
34 | }
35 | }
36 |
37 | - (BOOL)hasJSONContainer
38 | {
39 | return [self elementForName:XEP_0335_NAME xmlns:XEP_0335_XMLNS] != nil;
40 | }
41 |
42 | - (NSString *)JSONContainerString
43 | {
44 | return [[self JSONContainer] stringValue];
45 | }
46 |
47 | - (NSData *)JSONContainerData
48 | {
49 | NSString *JSONContainerString = [self JSONContainerString];
50 | return [JSONContainerString dataUsingEncoding:NSUTF8StringEncoding];
51 | }
52 |
53 | - (id)JSONContainerObject
54 | {
55 | NSData *JSONData = [self JSONContainerData];
56 | return [NSJSONSerialization JSONObjectWithData:JSONData options:0 error:nil];
57 | }
58 |
59 | - (void)addJSONContainerWithString:(NSString *)JSONContainerString
60 | {
61 | if([JSONContainerString length])
62 | {
63 | NSXMLElement *container = [NSXMLElement elementWithName:XEP_0335_NAME xmlns:XEP_0335_XMLNS];
64 | [container setStringValue:JSONContainerString];
65 | [self addChild:container];
66 | }
67 | }
68 |
69 | - (void)addJSONContainerWithData:(NSData *)JSONContainerData
70 | {
71 | if([JSONContainerData length])
72 | {
73 | NSString *JSONContainerString = [[NSString alloc] initWithData:JSONContainerData encoding:NSUTF8StringEncoding];
74 | [self addJSONContainerWithString:JSONContainerString];
75 | }
76 | }
77 |
78 | - (void)addJSONContainerWithObject:(id)JSONContainerObject
79 | {
80 | if([NSJSONSerialization isValidJSONObject:JSONContainerObject])
81 | {
82 | NSData *JSONContainerData = [NSJSONSerialization dataWithJSONObject:JSONContainerObject options:0 error:nil];
83 | [self addJSONContainerWithData:JSONContainerData];
84 | }
85 | }
86 |
87 | @end
88 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Utilities/DDList.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @class DDListEnumerator;
4 |
5 | struct DDListNode {
6 | void * element;
7 | struct DDListNode * prev;
8 | struct DDListNode * next;
9 | };
10 | typedef struct DDListNode DDListNode;
11 |
12 |
13 | /**
14 | * The DDList class is designed as a simple list class.
15 | * It can store objective-c objects as well as non-objective-c pointers.
16 | * It does not retain objective-c objects as it treats all elements as simple pointers.
17 | *
18 | * Example usages:
19 | * - Storing a list of delegates, where there is a desire to not retain the individual delegates.
20 | * - Storing a list of dispatch timers, which are not NSObjects, and cannot be stored in NSCollection classes.
21 | *
22 | * This class is NOT thread-safe.
23 | * It is designed to be used within a thread-safe context (e.g. within a single dispatch_queue).
24 | **/
25 | @interface DDList : NSObject
26 | {
27 | DDListNode *listHead;
28 | DDListNode *listTail;
29 | }
30 |
31 | - (void)add:(void *)element;
32 | - (void)remove:(void *)element;
33 | - (void)removeAll:(void *)element;
34 | - (void)removeAllElements;
35 |
36 | - (BOOL)contains:(void *)element;
37 |
38 | - (NSUInteger)count;
39 |
40 | /**
41 | * The enumerators return a snapshot of the list that can be enumerated.
42 | * The list can later be altered (elements added/removed) without affecting enumerator snapshots.
43 | **/
44 | - (DDListEnumerator *)listEnumerator;
45 | - (DDListEnumerator *)reverseListEnumerator;
46 |
47 | @end
48 |
49 | @interface DDListEnumerator : NSObject
50 | {
51 | NSUInteger numElements;
52 | NSUInteger currentElementIndex;
53 | void **elements;
54 | }
55 |
56 | - (NSUInteger)numTotal;
57 | - (NSUInteger)numLeft;
58 |
59 | - (void *)nextElement;
60 |
61 | @end
62 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Utilities/GCDMulticastDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @class GCDMulticastDelegateEnumerator;
4 |
5 | /**
6 | * This class provides multicast delegate functionality. That is:
7 | * - it provides a means for managing a list of delegates
8 | * - any method invocations to an instance of this class are automatically forwarded to all delegates
9 | *
10 | * For example:
11 | *
12 | * // Make this method call on every added delegate (there may be several)
13 | * [multicastDelegate cog:self didFindThing:thing];
14 | *
15 | * This allows multiple delegates to be added to an xmpp stream or any xmpp module,
16 | * which in turn makes development easier as there can be proper separation of logically different code sections.
17 | *
18 | * In addition, this makes module development easier,
19 | * as multiple delegates can usually be handled in a manner similar to the traditional single delegate paradigm.
20 | *
21 | * This class also provides proper support for GCD queues.
22 | * So each delegate specifies which queue they would like their delegate invocations to be dispatched onto.
23 | *
24 | * All delegate dispatching is done asynchronously (which is a critically important architectural design).
25 | **/
26 |
27 | @interface GCDMulticastDelegate : NSObject
28 |
29 | - (void)addDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue;
30 | - (void)removeDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue;
31 | - (void)removeDelegate:(id)delegate;
32 |
33 | - (void)removeAllDelegates;
34 |
35 | - (NSUInteger)count;
36 | - (NSUInteger)countOfClass:(Class)aClass;
37 | - (NSUInteger)countForSelector:(SEL)aSelector;
38 |
39 | - (BOOL)hasDelegateThatRespondsToSelector:(SEL)aSelector;
40 |
41 | - (GCDMulticastDelegateEnumerator *)delegateEnumerator;
42 |
43 | @end
44 |
45 |
46 | @interface GCDMulticastDelegateEnumerator : NSObject
47 |
48 | - (NSUInteger)count;
49 | - (NSUInteger)countOfClass:(Class)aClass;
50 | - (NSUInteger)countForSelector:(SEL)aSelector;
51 |
52 | - (BOOL)getNextDelegate:(id *)delPtr delegateQueue:(dispatch_queue_t *)dqPtr;
53 | - (BOOL)getNextDelegate:(id *)delPtr delegateQueue:(dispatch_queue_t *)dqPtr ofClass:(Class)aClass;
54 | - (BOOL)getNextDelegate:(id *)delPtr delegateQueue:(dispatch_queue_t *)dqPtr forSelector:(SEL)aSelector;
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Utilities/RFImageToDataTransformer.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | File: RFImageToDataTransformer.h
4 | Abstract: A value transformer, which transforms a UIImage or NSImage object into an NSData object.
5 |
6 | Based on Apple's UIImageToDataTransformer
7 |
8 | Copyright (C) 2010 Apple Inc. All Rights Reserved.
9 | Copyright (C) 2011 RF.com All Rights Reserved.
10 | */
11 |
12 | #import
13 |
14 |
15 | @interface RFImageToDataTransformer : NSValueTransformer {
16 |
17 | }
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Utilities/RFImageToDataTransformer.m:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | File: RFImageToDataTransformer.m
4 | Abstract: A value transformer, which transforms a UIImage or NSImage object into an NSData object.
5 |
6 | Based on Apple's UIImageToDataTransformer
7 |
8 | Copyright (C) 2010 Apple Inc. All Rights Reserved.
9 | Copyright (C) 2011 RF.com All Rights Reserved.
10 | */
11 |
12 | #import "RFImageToDataTransformer.h"
13 |
14 | #if TARGET_OS_IPHONE
15 | #import
16 | #else
17 |
18 | #endif
19 |
20 |
21 | @implementation RFImageToDataTransformer
22 |
23 | + (BOOL)allowsReverseTransformation {
24 | return YES;
25 | }
26 |
27 | + (Class)transformedValueClass {
28 | return [NSData class];
29 | }
30 |
31 | - (id)transformedValue:(id)value {
32 | #if TARGET_OS_IPHONE
33 | return UIImagePNGRepresentation(value);
34 | #else
35 | return [(NSImage *)value TIFFRepresentation];
36 | #endif
37 | }
38 |
39 | - (id)reverseTransformedValue:(id)value {
40 | #if TARGET_OS_IPHONE
41 | return [[UIImage alloc] initWithData:value];
42 | #else
43 | return [[NSImage alloc] initWithData:value];
44 | #endif
45 | }
46 |
47 | @end
48 |
49 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Utilities/XMPPSRVResolver.h:
--------------------------------------------------------------------------------
1 | //
2 | // XMPPSRVResolver.h
3 | //
4 | // Originally created by Eric Chamberlain on 6/15/10.
5 | // Based on SRVResolver by Apple, Inc.
6 | //
7 |
8 | #import
9 | #import
10 |
11 | extern NSString *const XMPPSRVResolverErrorDomain;
12 |
13 |
14 | @interface XMPPSRVResolver : NSObject
15 | {
16 | __unsafe_unretained id delegate;
17 | dispatch_queue_t delegateQueue;
18 |
19 | dispatch_queue_t resolverQueue;
20 | void *resolverQueueTag;
21 |
22 | __strong NSString *srvName;
23 | NSTimeInterval timeout;
24 |
25 | BOOL resolveInProgress;
26 |
27 | NSMutableArray *results;
28 | DNSServiceRef sdRef;
29 |
30 | int sdFd;
31 | dispatch_source_t sdReadSource;
32 | dispatch_source_t timeoutTimer;
33 | }
34 |
35 | /**
36 | * The delegate & delegateQueue are mandatory.
37 | * The resolverQueue is optional. If NULL, it will automatically create it's own internal queue.
38 | **/
39 | - (id)initWithdDelegate:(id)aDelegate delegateQueue:(dispatch_queue_t)dq resolverQueue:(dispatch_queue_t)rq;
40 |
41 | @property (strong, readonly) NSString *srvName;
42 | @property (readonly) NSTimeInterval timeout;
43 |
44 | - (void)startWithSRVName:(NSString *)aSRVName timeout:(NSTimeInterval)aTimeout;
45 | - (void)stop;
46 |
47 | + (NSString *)srvNameFromXMPPDomain:(NSString *)xmppDomain;
48 |
49 | @end
50 |
51 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
52 | #pragma mark -
53 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
54 |
55 | @protocol XMPPSRVResolverDelegate
56 |
57 | - (void)xmppSRVResolver:(XMPPSRVResolver *)sender didResolveRecords:(NSArray *)records;
58 | - (void)xmppSRVResolver:(XMPPSRVResolver *)sender didNotResolveDueToError:(NSError *)error;
59 |
60 | @end
61 |
62 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
63 | #pragma mark -
64 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
65 |
66 | @interface XMPPSRVRecord : NSObject
67 | {
68 | UInt16 priority;
69 | UInt16 weight;
70 | UInt16 port;
71 | NSString *target;
72 |
73 | NSUInteger sum;
74 | NSUInteger srvResultsIndex;
75 | }
76 |
77 | + (XMPPSRVRecord *)recordWithPriority:(UInt16)priority weight:(UInt16)weight port:(UInt16)port target:(NSString *)target;
78 |
79 | - (id)initWithPriority:(UInt16)priority weight:(UInt16)weight port:(UInt16)port target:(NSString *)target;
80 |
81 | @property (nonatomic, readonly) UInt16 priority;
82 | @property (nonatomic, readonly) UInt16 weight;
83 | @property (nonatomic, readonly) UInt16 port;
84 | @property (nonatomic, readonly) NSString *target;
85 |
86 | @end
87 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Utilities/XMPPStringPrep.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 |
4 | @interface XMPPStringPrep : NSObject
5 |
6 | /**
7 | * Preps a node identifier for use in a JID.
8 | * If the given node is invalid, this method returns nil.
9 | *
10 | * See the XMPP RFC (6120) for details.
11 | *
12 | * Note: The prep properly converts the string to lowercase, as per the RFC.
13 | **/
14 | + (NSString *)prepNode:(NSString *)node;
15 |
16 | /**
17 | * Preps a domain name for use in a JID.
18 | * If the given domain is invalid, this method returns nil.
19 | *
20 | * See the XMPP RFC (6120) for details.
21 | **/
22 | + (NSString *)prepDomain:(NSString *)domain;
23 |
24 | /**
25 | * Preps a resource identifier for use in a JID.
26 | * If the given node is invalid, this method returns nil.
27 | *
28 | * See the XMPP RFC (6120) for details.
29 | **/
30 | + (NSString *)prepResource:(NSString *)resource;
31 |
32 | /**
33 | * Preps a password with SASLprep profile.
34 | * If the given string is invalid, this method returns nil.
35 | *
36 | * See the SCRAM RFC (5802) for details.
37 | **/
38 |
39 | + (NSString *) prepPassword:(NSString *)password;
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Utilities/XMPPStringPrep.m:
--------------------------------------------------------------------------------
1 | #import "XMPPStringPrep.h"
2 | #import "stringprep.h"
3 |
4 |
5 | @implementation XMPPStringPrep
6 |
7 | + (NSString *)prepNode:(NSString *)node
8 | {
9 | if(node == nil) return nil;
10 |
11 | // Each allowable portion of a JID MUST NOT be more than 1023 bytes in length.
12 | // We make the buffer just big enough to hold a null-terminated string of this length.
13 | char buf[1024];
14 |
15 | strncpy(buf, [node UTF8String], sizeof(buf));
16 |
17 | if(stringprep_xmpp_nodeprep(buf, sizeof(buf)) != 0) return nil;
18 |
19 | return [NSString stringWithUTF8String:buf];
20 | }
21 |
22 | + (NSString *)prepDomain:(NSString *)domain
23 | {
24 | if(domain == nil) return nil;
25 |
26 | // Each allowable portion of a JID MUST NOT be more than 1023 bytes in length.
27 | // We make the buffer just big enough to hold a null-terminated string of this length.
28 | char buf[1024];
29 |
30 | strncpy(buf, [domain UTF8String], sizeof(buf));
31 |
32 | if(stringprep_nameprep(buf, sizeof(buf)) != 0) return nil;
33 |
34 | return [NSString stringWithUTF8String:buf];
35 | }
36 |
37 | + (NSString *)prepResource:(NSString *)resource
38 | {
39 | if(resource == nil) return nil;
40 |
41 | // Each allowable portion of a JID MUST NOT be more than 1023 bytes in length.
42 | // We make the buffer just big enough to hold a null-terminated string of this length.
43 | char buf[1024];
44 |
45 | strncpy(buf, [resource UTF8String], sizeof(buf));
46 |
47 | if(stringprep_xmpp_resourceprep(buf, sizeof(buf)) != 0) return nil;
48 |
49 | return [NSString stringWithUTF8String:buf];
50 | }
51 |
52 | + (NSString *)prepPassword:(NSString *)password
53 | {
54 | if(password == nil) return nil;
55 |
56 | // Each allowable portion of a JID MUST NOT be more than 1023 bytes in length.
57 | // We make the buffer just big enough to hold a null-terminated string of this length.
58 | char buf[1024];
59 |
60 | strncpy(buf, [password UTF8String], sizeof(buf));
61 |
62 | if(stringprep(buf, sizeof(buf), 0, stringprep_saslprep) != 0) return nil;
63 |
64 | return [NSString stringWithUTF8String:buf];
65 | }
66 |
67 | @end
68 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Utilities/XMPPTimer.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | /**
4 | * This class is a simple wrapper around dispatch_source_t timers.
5 | *
6 | * The primary motivation for this is to allow timers to be stored in collections.
7 | * But the class also makes it easier to code timers, as it simplifies the API.
8 | **/
9 | @interface XMPPTimer : NSObject
10 |
11 | /**
12 | * Creates an instance of a timer that will fire on the given queue.
13 | * It will invoke the given event handler block when it fires.
14 | **/
15 | - (instancetype)initWithQueue:(dispatch_queue_t)queue eventHandler:(dispatch_block_t)block;
16 |
17 | /**
18 | * Starts the timer.
19 | * It will first fire after the timeout.
20 | * After that, it will continue to fire every interval.
21 | *
22 | * The interval is optional.
23 | * If interval is zero (or negative), it will not use an interval (will only fire once after the timeout).
24 | *
25 | * This method can only be called once.
26 | **/
27 | - (void)startWithTimeout:(NSTimeInterval)timeout interval:(NSTimeInterval)interval;
28 |
29 | /**
30 | * Allows you to update an already started timer.
31 | *
32 | * The new timeout that you pass can be applied to 'now' or to the original start time of the timer.
33 | **/
34 | - (void)updateTimeout:(NSTimeInterval)timeout fromOriginalStartTime:(BOOL)useOriginalStartTime;
35 |
36 | /**
37 | * Cancels the timer so that it won't fire.
38 | **/
39 | - (void)cancel;
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Utilities/XMPPTimer.m:
--------------------------------------------------------------------------------
1 | #import "XMPPTimer.h"
2 | #import "XMPPLogging.h"
3 |
4 | // Log levels: off, error, warn, info, verbose
5 | // Log flags: trace
6 | #if DEBUG
7 | static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN;
8 | #else
9 | static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN;
10 | #endif
11 |
12 | @implementation XMPPTimer
13 | {
14 | BOOL isStarted;
15 |
16 | dispatch_time_t start;
17 | uint64_t timeout;
18 | uint64_t interval;
19 |
20 | dispatch_source_t timer;
21 | }
22 |
23 | - (instancetype)initWithQueue:(dispatch_queue_t)queue eventHandler:(dispatch_block_t)block
24 | {
25 | if ((self = [super init]))
26 | {
27 | timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
28 | dispatch_source_set_event_handler(timer, block);
29 |
30 | isStarted = NO;
31 | }
32 | return self;
33 | }
34 |
35 | - (void)dealloc
36 | {
37 | [self cancel];
38 | }
39 |
40 | - (void)startWithTimeout:(NSTimeInterval)inTimeout interval:(NSTimeInterval)inInterval
41 | {
42 | if (isStarted)
43 | {
44 | XMPPLogWarn(@"Unable to start timer - already started");
45 | return;
46 | }
47 |
48 | start = dispatch_time(DISPATCH_TIME_NOW, 0);
49 | timeout = (inTimeout * NSEC_PER_SEC);
50 | interval = (inInterval > 0.0) ? (inInterval * NSEC_PER_SEC) : DISPATCH_TIME_FOREVER;
51 |
52 | dispatch_source_set_timer(timer, dispatch_time(start, timeout), interval, 0);
53 | dispatch_resume(timer);
54 |
55 | isStarted = YES;
56 | }
57 |
58 | - (void)updateTimeout:(NSTimeInterval)inTimeout fromOriginalStartTime:(BOOL)useOriginalStartTime
59 | {
60 | if (!isStarted)
61 | {
62 | XMPPLogWarn(@"Unable to update timer - not yet started");
63 | return;
64 | }
65 |
66 | if (!useOriginalStartTime) {
67 | start = dispatch_time(DISPATCH_TIME_NOW, 0);
68 | }
69 | timeout = (inTimeout * NSEC_PER_SEC);
70 |
71 | dispatch_source_set_timer(timer, dispatch_time(start, timeout), interval, 0);
72 | }
73 |
74 | - (void)cancel
75 | {
76 | if (timer)
77 | {
78 | dispatch_source_cancel(timer);
79 | #if !OS_OBJECT_USE_OBJC
80 | dispatch_release(timer);
81 | #endif
82 | timer = NULL;
83 | }
84 | }
85 |
86 | @end
87 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Vendor/CocoaLumberjack/DDASLLogger.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import "DDLog.h"
5 |
6 | /**
7 | * Welcome to Cocoa Lumberjack!
8 | *
9 | * The project page has a wealth of documentation if you have any questions.
10 | * https://github.com/CocoaLumberjack/CocoaLumberjack
11 | *
12 | * If you're new to the project you may wish to read the "Getting Started" wiki.
13 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
14 | *
15 | *
16 | * This class provides a logger for the Apple System Log facility.
17 | *
18 | * As described in the "Getting Started" page,
19 | * the traditional NSLog() function directs it's output to two places:
20 | *
21 | * - Apple System Log
22 | * - StdErr (if stderr is a TTY) so log statements show up in Xcode console
23 | *
24 | * To duplicate NSLog() functionality you can simply add this logger and a tty logger.
25 | * However, if you instead choose to use file logging (for faster performance),
26 | * you may choose to use a file logger and a tty logger.
27 | **/
28 |
29 | @interface DDASLLogger : DDAbstractLogger
30 | {
31 | aslclient client;
32 | }
33 |
34 | + (instancetype)sharedInstance;
35 |
36 | // Inherited from DDAbstractLogger
37 |
38 | // - (id )logFormatter;
39 | // - (void)setLogFormatter:(id )formatter;
40 |
41 | @end
42 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Vendor/CocoaLumberjack/Extensions/DDContextFilterLogFormatter.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "DDLog.h"
3 |
4 | /**
5 | * Welcome to Cocoa Lumberjack!
6 | *
7 | * The project page has a wealth of documentation if you have any questions.
8 | * https://github.com/CocoaLumberjack/CocoaLumberjack
9 | *
10 | * If you're new to the project you may wish to read the "Getting Started" page.
11 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
12 | *
13 | *
14 | * This class provides a log formatter that filters log statements from a logging context not on the whitelist.
15 | *
16 | * A log formatter can be added to any logger to format and/or filter its output.
17 | * You can learn more about log formatters here:
18 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomFormatters
19 | *
20 | * You can learn more about logging context's here:
21 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomContext
22 | *
23 | * But here's a quick overview / refresher:
24 | *
25 | * Every log statement has a logging context.
26 | * These come from the underlying logging macros defined in DDLog.h.
27 | * The default logging context is zero.
28 | * You can define multiple logging context's for use in your application.
29 | * For example, logically separate parts of your app each have a different logging context.
30 | * Also 3rd party frameworks that make use of Lumberjack generally use their own dedicated logging context.
31 | **/
32 | @interface DDContextWhitelistFilterLogFormatter : NSObject
33 |
34 | - (id)init;
35 |
36 | - (void)addToWhitelist:(int)loggingContext;
37 | - (void)removeFromWhitelist:(int)loggingContext;
38 |
39 | - (NSArray *)whitelist;
40 |
41 | - (BOOL)isOnWhitelist:(int)loggingContext;
42 |
43 | @end
44 |
45 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
46 | #pragma mark -
47 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
48 |
49 | /**
50 | * This class provides a log formatter that filters log statements from a logging context on the blacklist.
51 | **/
52 | @interface DDContextBlacklistFilterLogFormatter : NSObject
53 |
54 | - (id)init;
55 |
56 | - (void)addToBlacklist:(int)loggingContext;
57 | - (void)removeFromBlacklist:(int)loggingContext;
58 |
59 | - (NSArray *)blacklist;
60 |
61 | - (BOOL)isOnBlacklist:(int)loggingContext;
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Vendor/CocoaLumberjack/Extensions/DDMultiFormatter.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "DDLog.h"
3 |
4 | /**
5 | * Welcome to Cocoa Lumberjack!
6 | *
7 | * The project page has a wealth of documentation if you have any questions.
8 | * https://github.com/CocoaLumberjack/CocoaLumberjack
9 | *
10 | * If you're new to the project you may wish to read the "Getting Started" page.
11 | * https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/GettingStarted
12 | *
13 | *
14 | * This formatter can be used to chain different formatters together.
15 | * The log message will processed in the order of the formatters added.
16 | **/
17 |
18 | @interface DDMultiFormatter : NSObject
19 |
20 | /**
21 | * Array of chained formatters
22 | */
23 | @property (readonly) NSArray *formatters;
24 |
25 | - (void)addFormatter:(id)formatter;
26 | - (void)removeFormatter:(id)formatter;
27 | - (void)removeAllFormatters;
28 | - (BOOL)isFormattingWithFormatter:(id)formatter;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Vendor/CocoaLumberjack/Extensions/README.txt:
--------------------------------------------------------------------------------
1 | This folder contains some sample formatters that may be helpful.
2 |
3 | Feel free to change them, extend them, or use them as the basis for your own custom formatter(s).
4 |
5 | More information about creating your own custom formatters can be found on the wiki:
6 | https://github.com/CocoaLumberjack/CocoaLumberjack/wiki/CustomFormatters
7 |
8 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Vendor/KissXML/Categories/NSString+DDXML.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 |
5 | @interface NSString (DDXML)
6 |
7 | /**
8 | * xmlChar - A basic replacement for char, a byte in a UTF-8 encoded string.
9 | **/
10 | - (const xmlChar *)xmlChar;
11 |
12 | - (NSString *)stringByTrimming;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Vendor/KissXML/Categories/NSString+DDXML.m:
--------------------------------------------------------------------------------
1 | #import "NSString+DDXML.h"
2 |
3 | #if ! __has_feature(objc_arc)
4 | #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
5 | #endif
6 |
7 | @implementation NSString (DDXML)
8 |
9 | - (const xmlChar *)xmlChar
10 | {
11 | return (const xmlChar *)[self UTF8String];
12 | }
13 |
14 | #ifdef GNUSTEP
15 | - (NSString *)stringByTrimming
16 | {
17 | return [self stringByTrimmingSpaces];
18 | }
19 | #else
20 | - (NSString *)stringByTrimming
21 | {
22 | NSMutableString *mStr = [self mutableCopy];
23 | CFStringTrimWhitespace((__bridge CFMutableStringRef)mStr);
24 |
25 | NSString *result = [mStr copy];
26 |
27 | return result;
28 | }
29 | #endif
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Vendor/KissXML/DDXMLElement.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "DDXMLNode.h"
3 |
4 | /**
5 | * Welcome to KissXML.
6 | *
7 | * The project page has documentation if you have questions.
8 | * https://github.com/robbiehanson/KissXML
9 | *
10 | * If you're new to the project you may wish to read the "Getting Started" wiki.
11 | * https://github.com/robbiehanson/KissXML/wiki/GettingStarted
12 | *
13 | * KissXML provides a drop-in replacement for Apple's NSXML class cluster.
14 | * The goal is to get the exact same behavior as the NSXML classes.
15 | *
16 | * For API Reference, see Apple's excellent documentation,
17 | * either via Xcode's Mac OS X documentation, or via the web:
18 | *
19 | * https://github.com/robbiehanson/KissXML/wiki/Reference
20 | **/
21 |
22 | @interface DDXMLElement : DDXMLNode
23 | {
24 | }
25 |
26 | - (id)initWithName:(NSString *)name;
27 | - (id)initWithName:(NSString *)name URI:(NSString *)URI;
28 | - (id)initWithName:(NSString *)name stringValue:(NSString *)string;
29 | - (id)initWithXMLString:(NSString *)string error:(NSError **)error;
30 |
31 | #pragma mark --- Elements by name ---
32 |
33 | - (NSArray *)elementsForName:(NSString *)name;
34 | - (NSArray *)elementsForLocalName:(NSString *)localName URI:(NSString *)URI;
35 |
36 | #pragma mark --- Attributes ---
37 |
38 | - (void)addAttribute:(DDXMLNode *)attribute;
39 | - (void)removeAttributeForName:(NSString *)name;
40 | - (void)setAttributes:(NSArray *)attributes;
41 | //- (void)setAttributesAsDictionary:(NSDictionary *)attributes;
42 | - (NSArray *)attributes;
43 | - (DDXMLNode *)attributeForName:(NSString *)name;
44 | //- (DDXMLNode *)attributeForLocalName:(NSString *)localName URI:(NSString *)URI;
45 |
46 | #pragma mark --- Namespaces ---
47 |
48 | - (void)addNamespace:(DDXMLNode *)aNamespace;
49 | - (void)removeNamespaceForPrefix:(NSString *)name;
50 | - (void)setNamespaces:(NSArray *)namespaces;
51 | - (NSArray *)namespaces;
52 | - (DDXMLNode *)namespaceForPrefix:(NSString *)prefix;
53 | - (DDXMLNode *)resolveNamespaceForName:(NSString *)name;
54 | - (NSString *)resolvePrefixForNamespaceURI:(NSString *)namespaceURI;
55 |
56 | #pragma mark --- Children ---
57 |
58 | - (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index;
59 | //- (void)insertChildren:(NSArray *)children atIndex:(NSUInteger)index;
60 | - (void)removeChildAtIndex:(NSUInteger)index;
61 | - (void)setChildren:(NSArray *)children;
62 | - (void)addChild:(DDXMLNode *)child;
63 | //- (void)replaceChildAtIndex:(NSUInteger)index withNode:(DDXMLNode *)node;
64 | //- (void)normalizeAdjacentTextNodesPreservingCDATA:(BOOL)preserve;
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Vendor/KissXML/DDXMLNode.m:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/XMPP/Vendor/KissXML/DDXMLNode.m
--------------------------------------------------------------------------------
/ChatDemo/XMPP/Vendor/libidn/libidn.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xhellohaley/ChatDemo/7a604115cfdb769af4e70dec014269867df7b36d/ChatDemo/XMPP/Vendor/libidn/libidn.a
--------------------------------------------------------------------------------
/ChatDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // ChatDemo
4 | //
5 | // Created by Joker on 15/7/19.
6 | // Copyright (c) 2015年 Mac. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ChatDemo/zh-Hans.lproj/Main.strings:
--------------------------------------------------------------------------------
1 |
2 | /* Class = "UITabBarItem"; title = "设置"; ObjectID = "1dP-c0-swP"; */
3 | "1dP-c0-swP.title" = "设置";
4 |
5 | /* Class = "UIButton"; normalTitle = "登录"; ObjectID = "Dw7-cW-mLA"; */
6 | "Dw7-cW-mLA.normalTitle" = "登录";
7 |
8 | /* Class = "UIButton"; normalTitle = "注册"; ObjectID = "IPm-Hy-tBi"; */
9 | "IPm-Hy-tBi.normalTitle" = "注册";
10 |
11 | /* Class = "UITextField"; placeholder = "密码"; ObjectID = "LPX-x0-u7W"; */
12 | "LPX-x0-u7W.placeholder" = "密码";
13 |
14 | /* Class = "UINavigationItem"; title = "通讯录"; ObjectID = "Ru0-QQ-fjH"; */
15 | "Ru0-QQ-fjH.title" = "通讯录";
16 |
17 | /* Class = "UINavigationItem"; title = "设置"; ObjectID = "X5K-6d-O6m"; */
18 | "X5K-6d-O6m.title" = "设置";
19 |
20 | /* Class = "UINavigationItem"; title = "注册"; ObjectID = "Z2S-aT-Qf7"; */
21 | "Z2S-aT-Qf7.title" = "注册";
22 |
23 | /* Class = "UITabBarItem"; title = "通讯录"; ObjectID = "uGJ-2Y-C4O"; */
24 | "uGJ-2Y-C4O.title" = "通讯录";
25 |
26 | /* Class = "UITextField"; placeholder = "用户名"; ObjectID = "yq6-r2-CsQ"; */
27 | "yq6-r2-CsQ.placeholder" = "用户名";
28 |
29 | /* Class = "UIButton"; normalTitle = "忘记密码?"; ObjectID = "zje-19-zpg"; */
30 | "zje-19-zpg.normalTitle" = "忘记密码?";
31 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ChatDemo
2 | 一个XMPP的详细实例。
3 | 代码中有比较详细的讲解和注释,最终实现登录、注册,获取好友列表、发送文字、发送语音、发送图片,创建群组,获取群列表的功能。
4 |
5 |
6 | # 更新记录
7 | 实现登录和注册功能。---2015-07-20
8 | 添加心跳检测和自动重连功能。---2015-07-22
9 | 添加获取好友列表和添加好友、处理好友申请的功能。---2015-07-23
10 | 添加获取本地历史消息、发送文本信息、接收文本信息的功能。----2015-07-24
11 | 添加创建群组,获取群列表的功能。-----2016-09-07
12 |
13 | # 项目截图
14 | 
15 | 
16 | 
17 | 
18 |
19 |
20 |
--------------------------------------------------------------------------------